mirror of
https://github.com/NixOS/nix
synced 2025-07-07 01:51:47 +02:00
Allows selectively adding environment variables to pure shells.
Includes documentation and test.
This commit is contained in:
parent
b27431b7cb
commit
438e02529d
3 changed files with 21 additions and 1 deletions
|
@ -4,12 +4,19 @@ clearStore
|
|||
|
||||
# Test nix-shell -A
|
||||
export IMPURE_VAR=foo
|
||||
export SELECTED_IMPURE_VAR=baz
|
||||
export NIX_BUILD_SHELL=$SHELL
|
||||
output=$(nix-shell --pure shell.nix -A shellDrv --run \
|
||||
'echo "$IMPURE_VAR - $VAR_FROM_STDENV_SETUP - $VAR_FROM_NIX"')
|
||||
|
||||
[ "$output" = " - foo - bar" ]
|
||||
|
||||
# Test --keep
|
||||
output=$(nix-shell --pure --keep SELECTED_IMPURE_VAR shell.nix -A shellDrv --run \
|
||||
'echo "$IMPURE_VAR - $VAR_FROM_STDENV_SETUP - $VAR_FROM_NIX - $SELECTED_IMPURE_VAR"')
|
||||
|
||||
[ "$output" = " - foo - bar - baz" ]
|
||||
|
||||
# Test nix-shell on a .drv
|
||||
[[ $(nix-shell --pure $(nix-instantiate shell.nix -A shellDrv) --run \
|
||||
'echo "$IMPURE_VAR - $VAR_FROM_STDENV_SETUP - $VAR_FROM_NIX"') = " - foo - bar" ]]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue