mirror of
https://github.com/nix-community/home-manager
synced 2024-11-25 06:00:31 +00:00
direnv: remove nushell hack
This commit is contained in:
parent
1834304bc3
commit
cb93ab1c99
2 changed files with 5 additions and 28 deletions
|
@ -130,39 +130,16 @@ in {
|
|||
${getExe cfg.package} hook fish | source
|
||||
'');
|
||||
|
||||
programs.nushell.extraConfig = mkIf cfg.enableNushellIntegration (let
|
||||
# We want to get the stdout from direnv even if it exits with non-zero,
|
||||
# because it will have the DIRENV_ internal variables defined.
|
||||
#
|
||||
# However, nushell's current implementation of try-catch is subtly
|
||||
# broken with external commands in pipelines[0].
|
||||
#
|
||||
# This means we don't have a good way to ignore the exit code
|
||||
# without using do | complete, which has a side effect of also
|
||||
# capturing stderr, which we don't want.
|
||||
#
|
||||
# So, as a workaround, we wrap nushell in a second script that
|
||||
# just ignores the exit code and does nothing else, allowing
|
||||
# nushell to capture our stdout, but letting stderr go through
|
||||
# and not causing a spurious "command failed" message.
|
||||
#
|
||||
# [0]: https://github.com/nushell/nushell/issues/13868
|
||||
#
|
||||
# FIXME: remove the wrapper once the upstream issue is fixed
|
||||
|
||||
direnvWrapped = pkgs.writeShellScript "direnv-wrapped" ''
|
||||
${getExe cfg.package} export json || true
|
||||
'';
|
||||
# Using mkAfter to make it more likely to appear after other
|
||||
# manipulations of the prompt.
|
||||
in mkAfter ''
|
||||
# Using mkAfter to make it more likely to appear after other
|
||||
# manipulations of the prompt.
|
||||
programs.nushell.extraConfig = mkIf cfg.enableNushellIntegration (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 {||
|
||||
${direnvWrapped}
|
||||
${getExe cfg.package} export json
|
||||
| from json --strict
|
||||
| default {}
|
||||
| items {|key, value|
|
||||
|
|
|
@ -13,6 +13,6 @@
|
|||
"home-files/.config/nushell/config.nu";
|
||||
in ''
|
||||
assertFileExists "${configFile}"
|
||||
assertFileRegex "${configFile}" '/nix/store/.*direnv-wrapped'
|
||||
assertFileRegex "${configFile}" '/nix/store/.*direnv.*/bin/direnv export json'
|
||||
'';
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue