#!/nix/var/nix/profiles/execline/bin/execlineb -W # Execute things in an ephemeral nix environment context, with similar # syntax as `guix environment --ad-hoc`: # nix-environment [ ... ] -- \ # command [ [ ... ]] /nix/var/nix/profiles/execline/bin/define EL_BIN /nix/var/nix/profiles/execline/bin ${EL_BIN}/import PATH ${EL_BIN}/export PATH ${EL_BIN}:$PATH ${EL_BIN}/importas -i PACKAGE 1 ifelse { redirfd -w 1 /dev/null expr -- $PACKAGE != -- } { ifelse { redirfd -w 1 /dev/null import \# expr $\# = 0 } { fdmove 1 2 echo "The '--' argument is required" exit 1 } backtick PACKAGE_NETSTRING { execlineb -c "dollarat -d \"\"" $PACKAGE } multisubstitute { import PACKAGE_NETSTRING import -D "" NIX_ENVIRONMENT_PACKAGES } export NIX_ENVIRONMENT_PACKAGES ${NIX_ENVIRONMENT_PACKAGES}${PACKAGE_NETSTRING} importas -i SELF 0 shift elgetpositionals emptyenv -P export PATH $PATH ${EL_BIN}/execlineb $SELF $@ } shift import -u -s -d "" NIX_ENVIRONMENT_PACKAGES export PATH $PATH nix-shell -p $NIX_ENVIRONMENT_PACKAGES --run "exec '${EL_BIN}/elgetpositionals' \\$@"