From db0e37ea656a1983c21b6bd4529a7365f7d0c26a Mon Sep 17 00:00:00 2001 From: Quentin Aristote Date: Fri, 21 Oct 2022 12:18:32 +0200 Subject: [PATCH] test_gc: force change of env by passing arg to shell.nix --- tests/test_gc.py | 4 +--- tests/testenv/shell.nix | 15 ++++++--------- 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/tests/test_gc.py b/tests/test_gc.py index e93a18c..12240b6 100644 --- a/tests/test_gc.py +++ b/tests/test_gc.py @@ -64,8 +64,7 @@ def test_use_nix(direnv_project: DirenvProject) -> None: direnv_project.setup_envrc("use nix") common_test(direnv_project) - # --pure here is just a way to make sure the environment changes - direnv_project.setup_envrc("use nix --pure") + direnv_project.setup_envrc("use nix --argstr 'echo Executing hijacked shellHook.'") common_test_clean(direnv_project) @@ -81,7 +80,6 @@ def test_use_flake(direnv_project: DirenvProject) -> None: for symlink in inputs: assert symlink.is_dir() - # --impure here is just a way to make sure the environment changes direnv_project.setup_envrc("use flake --impure") common_test_clean(direnv_project) diff --git a/tests/testenv/shell.nix b/tests/testenv/shell.nix index c5c9d85..05d0a7a 100644 --- a/tests/testenv/shell.nix +++ b/tests/testenv/shell.nix @@ -1,14 +1,11 @@ -{ pkgs ? import {}, someArg ? null }: +{ pkgs ? import { }, someArg ? null, shellHook ? '' + echo "Executing shellHook." +'' }: pkgs.mkShellNoCC { + inherit shellHook; + nativeBuildInputs = [ pkgs.hello ]; - shellHook = '' - echo "Executing shellHook." - ''; SHOULD_BE_SET = someArg; - passthru = { - subshell = pkgs.mkShellNoCC { - THIS_IS_A_SUBSHELL = "OK"; - }; - }; + passthru = { subshell = pkgs.mkShellNoCC { THIS_IS_A_SUBSHELL = "OK"; }; }; }