1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2024-12-26 03:39:47 +01:00

direnv: Make lines shorter

This commit is contained in:
Joaquín Triñanes 2023-12-18 03:16:52 +01:00 committed by Mikilio
parent 998e70eb82
commit a05cca1dcc
No known key found for this signature in database
GPG key ID: 5B2F1A890CF33F3F
2 changed files with 27 additions and 15 deletions

View file

@ -134,10 +134,13 @@ in {
mkAfter '' mkAfter ''
$env.config = ($env.config? | default {}) $env.config = ($env.config? | default {})
$env.config.hooks = ($env.config.hooks? | default {}) $env.config.hooks = ($env.config.hooks? | default {})
$env.config.hooks.pre_prompt = ($env.config.hooks.pre_prompt? | default [] | append {|| $env.config.hooks.pre_prompt = (
let direnv = (${ $env.config.hooks.pre_prompt?
getExe cfg.package | default []
} export json | from json | default {}) | append {||
let direnv = (${getExe cfg.package} export json
| from json
| default {})
if ($direnv | is-empty) { if ($direnv | is-empty) {
return return
} }
@ -145,10 +148,19 @@ in {
| items {|key, value| | items {|key, value|
{ {
key: $key key: $key
value: (do ($env.ENV_CONVERSIONS? | default {} | get -i $key | get -i from_string | default {|x| $x}) $value) value: (do (
$env.env_conversions?
| default {}
| get -i $key
| get -i from_string
| default {|x| $x}
) $value)
} }
} | transpose -ird | load-env }
}) | transpose -ird
| load-env
}
)
''); '');
}; };
} }

View file

@ -14,6 +14,6 @@
in '' in ''
assertFileExists "${configFile}" assertFileExists "${configFile}"
assertFileRegex "${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$'
''; '';
} }