git ssb

0+

clacke / gists



Commit c3f5635d0422027748290dbc3838b94ab69ad5a7

nix-environment: gone Full Execline

Claes Wallin (韋嘉誠) committed on 10/15/2016, 4:05:56 PM
Parent: 03e288c9b9e4d60e7d19ac8bd0cdaa7b052221ec

Files changed

bin/nix-environmentchanged
bin/nix-environmentView
@@ -1,26 +1,48 @@
1-#!/usr/bin/env bash
1 +#!/nix/var/nix/profiles/execline/bin/execlineb -W
22
33 # Execute things in an ephemeral nix environment context, with similar
44 # syntax as `guix environment --ad-hoc`:
55 # nix-environment <package_1> [ ... <package_n> ] -- \
66 # command [ <arg_1> [ ... <arg_n>]]
77
8-EL_BIN=/nix/var/nix/profiles/execline/bin
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
911
10-while (( $# >= 1 )); do
11- if [[ $1 == "--" ]]; then
12- shift
13- break
14- fi
15- packages+=( "$1" )
12 +${EL_BIN}/importas -i PACKAGE 1
13 +
14 +ifelse {
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
1638 shift
17-done
18-
19-export PACKAGES=$(PATH=${EL_BIN}:$PATH execlineb -c 'dollarat -d ""' "${packages[@]}")
20-
21-exec ${EL_BIN}/execlineb -c "
22- ${EL_BIN}/import -u EL_BIN"'
23- ${EL_BIN}/import -u -s -d "" PACKAGES
24- nix-shell -p $PACKAGES --run
25- "exec '"'"'${EL_BIN}/elgetpositionals'"'"' \\$@"
26-' "$@"
39 + elgetpositionals
40 + emptyenv -P
41 + export PATH $PATH
42 + ${EL_BIN}/execlineb $SELF $@
43 +}
44 +shift
45 +import -u -s -d "" NIX_ENVIRONMENT_PACKAGES
46 +export PATH $PATH
47 +nix-shell -p $NIX_ENVIRONMENT_PACKAGES --run
48 + "exec '${EL_BIN}/elgetpositionals' \\$@"

Built with git-ssb-web