diff --git a/modules/programs/direnv.nix b/modules/programs/direnv.nix index 4a7636705..ccfe00e6d 100644 --- a/modules/programs/direnv.nix +++ b/modules/programs/direnv.nix @@ -140,9 +140,15 @@ in { $env.config.hooks.pre_prompt? | default [] | append {|| - let direnv = (${getExe cfg.package} export json - | from json - | default {}) + let direnv = ( + try { + ${getExe cfg.package} export json + } catch { + "" + } + | from json + | default {} + ) if ($direnv | is-empty) { return } diff --git a/tests/modules/programs/direnv/nushell.nix b/tests/modules/programs/direnv/nushell.nix index 6655f01a8..2304b8b68 100644 --- a/tests/modules/programs/direnv/nushell.nix +++ b/tests/modules/programs/direnv/nushell.nix @@ -14,6 +14,6 @@ in '' assertFileExists "${configFile}" assertFileRegex "${configFile}" \ - '^\s*let direnv = (/nix/store/.*direnv.*/bin/direnv export json$' + '^\s*/nix/store/.*direnv.*/bin/direnv export json$' ''; }