From 8c35eb15dbfceeb5651c1c3680c4193e08fa1c73 Mon Sep 17 00:00:00 2001 From: Benedikt Peetz Date: Wed, 26 Aug 2026 00:08:12 +0200 Subject: modules/direnv: Correctly express condition for landlock shell spawn --- modules/by-name/di/direnv/module.nix | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/modules/by-name/di/direnv/module.nix b/modules/by-name/di/direnv/module.nix index 9c2975c3..fc800f35 100644 --- a/modules/by-name/di/direnv/module.nix +++ b/modules/by-name/di/direnv/module.nix @@ -52,10 +52,19 @@ in { ${direnvPkg} export fish | source end - function _direnv_hook --on-event fish_preexec --on-variable PWD - if not set --query IN_DIRENV_SANDBOX; and set --query SHOULD_SANDBOX_DIRENV; and ${direnvPkg} status | grep 'Found RC path' --invert-match | grep 'No .envrc or .env loaded' --quiet - # We found a rc path, but none are loaded. So we can start our shell. - ${lib.getExe landrun-fish} --interactive --command='_direnv_export_eval' + function _direnv_hook --on-variable PWD + if not set --query IN_DIRENV_SANDBOX; + and set --query SHOULD_SANDBOX_DIRENV; + and ${direnvPkg} status | grep 'Found RC path' --quiet; + and ${direnvPkg} status | grep 'No .envrc or .env loaded' --quiet + + # We found a RC path, but no RC file is loaded. So we can start our shell and + # load it. + ${lib.getExe landrun-fish} --init-command='_direnv_export_eval' + + # After the user exists (via Ctrl+D), they probably want to change the + # directory. + ll else _direnv_export_eval end -- cgit v1.3.1