aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authoreldritch horrors <pennae@lix.systems>2024-03-04 07:59:32 +0100
committereldritch horrors <pennae@lix.systems>2024-03-04 07:59:32 +0100
commite310bbf913ba068e1669c57de255cb811422fe8b (patch)
tree5c78e70e64d660a2d7afa2b2adad2edff8ea12ca /tests
parent180984178dc4e063607f6e9e94eb2fdfedbfe452 (diff)
Merge pull request #8043 from bobvanderlinden/pr-shell-env
nix: develop: use SHELL from rc script (cherry picked from commit 0d55d660d5ea081630aa9606b047eb755cff1528) Change-Id: I83be6c63b282d7f01a0defa78d9e787c77f1f02d
Diffstat (limited to 'tests')
-rw-r--r--tests/functional/common/vars-and-functions.sh.in1
-rw-r--r--tests/functional/flakes/develop.sh67
-rw-r--r--tests/functional/local.mk1
3 files changed, 69 insertions, 0 deletions
diff --git a/tests/functional/common/vars-and-functions.sh.in b/tests/functional/common/vars-and-functions.sh.in
index 967d6be54..0bde0180f 100644
--- a/tests/functional/common/vars-and-functions.sh.in
+++ b/tests/functional/common/vars-and-functions.sh.in
@@ -45,6 +45,7 @@ if [[ -n "${NIX_DAEMON_PACKAGE:-}" ]]; then
DAEMON_PATH="${NIX_DAEMON_PACKAGE}/bin:$DAEMON_PATH"
fi
coreutils=@coreutils@
+lsof=@lsof@
export dot=@dot@
export SHELL="@bash@"
diff --git a/tests/functional/flakes/develop.sh b/tests/functional/flakes/develop.sh
new file mode 100644
index 000000000..e1e53d364
--- /dev/null
+++ b/tests/functional/flakes/develop.sh
@@ -0,0 +1,67 @@
+source ../common.sh
+
+clearStore
+rm -rf $TEST_HOME/.cache $TEST_HOME/.config $TEST_HOME/.local
+
+# Create flake under test.
+cp ../shell-hello.nix ../config.nix $TEST_HOME/
+cat <<EOF >$TEST_HOME/flake.nix
+{
+ inputs.nixpkgs.url = "$TEST_HOME/nixpkgs";
+ outputs = {self, nixpkgs}: {
+ packages.$system.hello = (import ./config.nix).mkDerivation {
+ name = "hello";
+ outputs = [ "out" "dev" ];
+ meta.outputsToInstall = [ "out" ];
+ buildCommand = "";
+ };
+ };
+}
+EOF
+
+# Create fake nixpkgs flake.
+mkdir -p $TEST_HOME/nixpkgs
+cp ../config.nix ../shell.nix $TEST_HOME/nixpkgs
+cat <<EOF >$TEST_HOME/nixpkgs/flake.nix
+{
+ outputs = {self}: {
+ legacyPackages.$system.bashInteractive = (import ./shell.nix {}).bashInteractive;
+ };
+}
+EOF
+
+cd $TEST_HOME
+
+# Test whether `nix develop` passes through environment variables.
+[[ "$(
+ ENVVAR=a nix develop --no-write-lock-file .#hello <<EOF
+echo "\$ENVVAR"
+EOF
+)" = "a" ]]
+
+# Test whether `nix develop --ignore-environment` does _not_ pass through environment variables.
+[[ -z "$(
+ ENVVAR=a nix develop --ignore-environment --no-write-lock-file .#hello <<EOF
+echo "\$ENVVAR"
+EOF
+)" ]]
+
+# Determine the bashInteractive executable.
+nix build --no-write-lock-file './nixpkgs#bashInteractive' --out-link ./bash-interactive
+BASH_INTERACTIVE_EXECUTABLE="$PWD/bash-interactive/bin/bash"
+
+# Test whether `nix develop` sets `SHELL` to nixpkgs#bashInteractive shell.
+[[ "$(
+ SHELL=custom nix develop --no-write-lock-file .#hello <<EOF
+echo "\$SHELL"
+EOF
+)" -ef "$BASH_INTERACTIVE_EXECUTABLE" ]]
+
+# Test whether `nix develop` with ignore environment sets `SHELL` to nixpkgs#bashInteractive shell.
+[[ "$(
+ SHELL=custom nix develop --ignore-environment --no-write-lock-file .#hello <<EOF
+echo "\$SHELL"
+EOF
+)" -ef "$BASH_INTERACTIVE_EXECUTABLE" ]]
+
+clearStore
diff --git a/tests/functional/local.mk b/tests/functional/local.mk
index 9d69c925b..24d772cc7 100644
--- a/tests/functional/local.mk
+++ b/tests/functional/local.mk
@@ -2,6 +2,7 @@ nix_tests = \
test-infra.sh \
init.sh \
flakes/flakes.sh \
+ flakes/develop.sh \
flakes/run.sh \
flakes/mercurial.sh \
flakes/circular.sh \