1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2024-11-26 21:19:45 +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 Robert Helgesson
parent bc52cdd579
commit 3bfaacf461
No known key found for this signature in database
GPG key ID: 36BDAA14C2797E89
2 changed files with 27 additions and 15 deletions

View file

@ -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
}
)
'');
};
}

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$'
'';
}