diff --git a/modules/programs/direnv.nix b/modules/programs/direnv.nix index 3ed5fdf1..e3b9de2b 100644 --- a/modules/programs/direnv.nix +++ b/modules/programs/direnv.nix @@ -134,21 +134,33 @@ in { mkAfter '' $env.config = ($env.config? | default {}) $env.config.hooks = ($env.config.hooks? | default {}) - $env.config.hooks.pre_prompt = ($env.config.hooks.pre_prompt? | default [] | append {|| - let direnv = (${ - getExe cfg.package - } export json | from json | default {}) - if ($direnv | is-empty) { - return - } - $direnv - | items {|key, value| - { - key: $key - value: (do ($env.ENV_CONVERSIONS? | default {} | get -i $key | get -i from_string | default {|x| $x}) $value) + $env.config.hooks.pre_prompt = ( + $env.config.hooks.pre_prompt? + | default [] + | append {|| + let direnv = (${getExe cfg.package} export json + | from json + | default {}) + if ($direnv | is-empty) { + return } - } | transpose -ird | load-env - }) + $direnv + | items {|key, value| + { + key: $key + value: (do ( + $env.env_conversions? + | default {} + | get -i $key + | get -i from_string + | default {|x| $x} + ) $value) + } + } + | transpose -ird + | load-env + } + ) ''); }; } diff --git a/tests/modules/programs/direnv/nushell.nix b/tests/modules/programs/direnv/nushell.nix index c202a6f8..46f34ebd 100644 --- a/tests/modules/programs/direnv/nushell.nix +++ b/tests/modules/programs/direnv/nushell.nix @@ -14,6 +14,6 @@ in '' assertFileExists "${configFile}" assertFileRegex "${configFile}" \ - 'let direnv = (/nix/store/.*direnv.*/bin/direnv export json \| from json | default {})' + '^\s*let direnv = (/nix/store/.*direnv.*/bin/direnv export json$' ''; }