1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2024-12-25 19:29: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 ''
$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 {})
$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
}
@ -145,10 +148,19 @@ in {
| items {|key, value|
{
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 ''
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$'
'';
}