diff --git a/direnvrc b/direnvrc index eb14d850..931975d5 100644 --- a/direnvrc +++ b/direnvrc @@ -135,6 +135,7 @@ use_flake() { log_status renewed cache else + sed -i '/eval \"\$shellHook\"/d' "$profile_rc" log_status using cached dev shell fi diff --git a/tests/test.py b/tests/test.py index 74f24205..a7a83e0a 100644 --- a/tests/test.py +++ b/tests/test.py @@ -55,6 +55,7 @@ def test_nix_shell(self) -> None: ) sys.stderr.write(out1.stderr) self.assertIn("renewed cache and derivation link", out1.stderr) + self.assertIn("Executing shellHook.", out1.stderr) self.assertEqual(out1.returncode, 0) run(["nix-collect-garbage"], check=True) @@ -67,6 +68,7 @@ def test_nix_shell(self) -> None: ) sys.stderr.write(out2.stderr) self.assertIn("using cached derivation", out2.stderr) + self.assertNotIn("Executing shellHook.", out2.stderr) self.assertEqual(out2.returncode, 0) @unittest.skipUnless(support_flakes(), "requires flakes") @@ -86,6 +88,7 @@ def test_nix_flake(self) -> None: ) sys.stderr.write(out1.stderr) self.assertIn("renewed cache", out1.stderr) + self.assertIn("Executing shellHook.", out1.stderr) self.assertEqual(out1.returncode, 0) run(["nix-collect-garbage"], check=True) @@ -107,6 +110,7 @@ def test_nix_flake(self) -> None: for symlink in inputs: self.assertTrue(symlink.is_dir()) self.assertIn("using cached dev shell", out2.stderr) + self.assertNotIn("Executing shellHook.", out2.stderr) self.assertEqual(out2.returncode, 0) diff --git a/tests/testenv/shell.nix b/tests/testenv/shell.nix index 7437fb7d..ed38bd32 100644 --- a/tests/testenv/shell.nix +++ b/tests/testenv/shell.nix @@ -1,4 +1,7 @@ { pkgs ? import {} }: pkgs.mkShell { nativeBuildInputs = [ pkgs.hello ]; + shellHook = '' + echo "Executing shellHook." + ''; }