git ssb

0+

clacke / gists



Tree: 1cf860d974728c39c94da1fb66c1706103237ea5

Files: 1cf860d974728c39c94da1fb66c1706103237ea5 / bin / nix-environment

1173 bytesRaw
1#!/nix/var/nix/profiles/execline/bin/execlineb -W
2
3# Execute things in an ephemeral nix environment context, with similar
4# syntax as `guix environment --ad-hoc`:
5# nix-environment <package_1> [ ... <package_n> ] -- \
6# command [ <arg_1> [ ... <arg_n>]]
7
8/nix/var/nix/profiles/execline/bin/define EL_BIN /nix/var/nix/profiles/execline/bin
9${EL_BIN}/import PATH
10${EL_BIN}/export PATH ${EL_BIN}:$PATH
11
12${EL_BIN}/importas -i PACKAGE 1
13
14ifelse {
15 redirfd -w 1 /dev/null
16 expr -- $PACKAGE != --
17}
18{
19 ifelse {
20 redirfd -w 1 /dev/null
21 import \#
22 expr $\# = 0
23 }
24 {
25 fdmove 1 2
26 echo "The '--' argument is required"
27 exit 1
28 }
29 backtick PACKAGE_NETSTRING {
30 execlineb -c "dollarat -d \"\"" $PACKAGE
31 }
32 multisubstitute {
33 import PACKAGE_NETSTRING
34 import -D "" NIX_ENVIRONMENT_PACKAGES
35 }
36 export NIX_ENVIRONMENT_PACKAGES ${NIX_ENVIRONMENT_PACKAGES}${PACKAGE_NETSTRING}
37 importas -i SELF 0
38 shift
39 elgetpositionals
40 emptyenv -P
41 export PATH $PATH
42 ${EL_BIN}/execlineb $SELF $@
43}
44shift
45import -u -s -d "" NIX_ENVIRONMENT_PACKAGES
46export PATH $PATH
47nix-shell -p $NIX_ENVIRONMENT_PACKAGES --run
48 "exec '${EL_BIN}/elgetpositionals' \\$@"

Built with git-ssb-web