diff options
author | Samuel Dionne-Riel <samuel@dionne-riel.com> | 2018-08-02T01·28-0400 |
---|---|---|
committer | Samuel Dionne-Riel <samuel@dionne-riel.com> | 2018-08-02T12·21-0400 |
commit | 438e02529dfb4b26603e2a06992df977cd80ecd9 (patch) | |
tree | c7545b9b40190ce2c60e12e536243db70d7b1edb /tests/nix-shell.sh | |
parent | b27431b7cb918e6866f4bb4fa7ec6e23240cfeab (diff) |
Allows selectively adding environment variables to pure shells.
Includes documentation and test.
Diffstat (limited to 'tests/nix-shell.sh')
-rw-r--r-- | tests/nix-shell.sh | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/tests/nix-shell.sh b/tests/nix-shell.sh index d25c456cedfb..6024ea399750 100644 --- a/tests/nix-shell.sh +++ b/tests/nix-shell.sh @@ -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" ]] |