1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2024-09-21 05:47:29 +02: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,21 +134,33 @@ 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 {||
if ($direnv | is-empty) { let direnv = (${getExe cfg.package} export json
return | from json
} | default {})
$direnv if ($direnv | is-empty) {
| items {|key, value| return
{
key: $key
value: (do ($env.ENV_CONVERSIONS? | default {} | get -i $key | get -i from_string | default {|x| $x}) $value)
} }
} | 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 '' 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$'
''; '';
} }