git ssb

0+

clacke / gists



Commit 5d7c526593021a9cf8f0a19bb829d355b383f2d1

nix-environment: Use netstring and execline import to eliminate the pipe and xargs

Claes Wallin (韋嘉誠) committed on 10/15/2016, 10:10:49 AM
Parent: a30d3c7d4c16b027c405969595df0d81e565b73c

Files changed

bin/nix-environmentchanged
bin/nix-environmentView
@@ -1,10 +1,8 @@
11 #!/usr/bin/env bash
22
33 EL_BIN=/nix/var/nix/profiles/execline/bin
44
5-packages=()
6-
75 while (( $# >= 1 )); do
86 if [[ $1 == "--" ]]; then
97 shift
108 break
@@ -12,7 +10,7 @@
1210 packages+=( "$1" )
1311 shift
1412 done
1513
16-exec 3<&0
17-printf '%s\0' "$@" |
18- nix-shell -p "${packages[@]}" --run "xargs -0 bash -c 'exec <&3- \"\$@\"' nix-environment"
14 +export PARAMS=$(${EL_BIN}/execlineb -c "${EL_BIN}/dollarat"' -d ""' "$@")
15 +
16 +exec nix-shell -p "${packages[@]}" --run "${EL_BIN}/import -s -d '' PARAMS '\$PARAMS'"

Built with git-ssb-web