mirror of
https://github.com/nix-community/nix-direnv.git
synced 2025-11-08 19:46:11 +01:00
flakes: Don't run shellHook on cached dev shells
This makes the behavior of `use flake` consistent with that of `use nix`. Resolve #90.
This commit is contained in:
parent
4cb1aa4f10
commit
6e68ea7235
3 changed files with 8 additions and 0 deletions
1
direnvrc
1
direnvrc
|
|
@ -135,6 +135,7 @@ use_flake() {
|
||||||
|
|
||||||
log_status renewed cache
|
log_status renewed cache
|
||||||
else
|
else
|
||||||
|
sed -i "/eval \"\$shellHook\"/d" "$profile_rc"
|
||||||
log_status using cached dev shell
|
log_status using cached dev shell
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -55,6 +55,7 @@ class IntegrationTest(unittest.TestCase):
|
||||||
)
|
)
|
||||||
sys.stderr.write(out1.stderr)
|
sys.stderr.write(out1.stderr)
|
||||||
self.assertIn("renewed cache and derivation link", out1.stderr)
|
self.assertIn("renewed cache and derivation link", out1.stderr)
|
||||||
|
self.assertIn("Executing shellHook.", out1.stderr)
|
||||||
self.assertEqual(out1.returncode, 0)
|
self.assertEqual(out1.returncode, 0)
|
||||||
|
|
||||||
run(["nix-collect-garbage"], check=True)
|
run(["nix-collect-garbage"], check=True)
|
||||||
|
|
@ -67,6 +68,7 @@ class IntegrationTest(unittest.TestCase):
|
||||||
)
|
)
|
||||||
sys.stderr.write(out2.stderr)
|
sys.stderr.write(out2.stderr)
|
||||||
self.assertIn("using cached derivation", out2.stderr)
|
self.assertIn("using cached derivation", out2.stderr)
|
||||||
|
self.assertNotIn("Executing shellHook.", out2.stderr)
|
||||||
self.assertEqual(out2.returncode, 0)
|
self.assertEqual(out2.returncode, 0)
|
||||||
|
|
||||||
@unittest.skipUnless(support_flakes(), "requires flakes")
|
@unittest.skipUnless(support_flakes(), "requires flakes")
|
||||||
|
|
@ -86,6 +88,7 @@ class IntegrationTest(unittest.TestCase):
|
||||||
)
|
)
|
||||||
sys.stderr.write(out1.stderr)
|
sys.stderr.write(out1.stderr)
|
||||||
self.assertIn("renewed cache", out1.stderr)
|
self.assertIn("renewed cache", out1.stderr)
|
||||||
|
self.assertIn("Executing shellHook.", out1.stderr)
|
||||||
self.assertEqual(out1.returncode, 0)
|
self.assertEqual(out1.returncode, 0)
|
||||||
|
|
||||||
run(["nix-collect-garbage"], check=True)
|
run(["nix-collect-garbage"], check=True)
|
||||||
|
|
@ -107,6 +110,7 @@ class IntegrationTest(unittest.TestCase):
|
||||||
for symlink in inputs:
|
for symlink in inputs:
|
||||||
self.assertTrue(symlink.is_dir())
|
self.assertTrue(symlink.is_dir())
|
||||||
self.assertIn("using cached dev shell", out2.stderr)
|
self.assertIn("using cached dev shell", out2.stderr)
|
||||||
|
self.assertNotIn("Executing shellHook.", out2.stderr)
|
||||||
|
|
||||||
self.assertEqual(out2.returncode, 0)
|
self.assertEqual(out2.returncode, 0)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,7 @@
|
||||||
{ pkgs ? import <nixpkgs> {} }:
|
{ pkgs ? import <nixpkgs> {} }:
|
||||||
pkgs.mkShell {
|
pkgs.mkShell {
|
||||||
nativeBuildInputs = [ pkgs.hello ];
|
nativeBuildInputs = [ pkgs.hello ];
|
||||||
|
shellHook = ''
|
||||||
|
echo "Executing shellHook."
|
||||||
|
'';
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue