mirror of
https://github.com/thegeneralist01/config.git
synced 2026-03-07 10:59:55 +01:00
config: command-line revamp
This commit is contained in:
parent
802a38f61b
commit
3f34891413
28 changed files with 1141 additions and 335 deletions
44
modules/common/shell/direnv.nix
Normal file
44
modules/common/shell/direnv.nix
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
{ lib, ... }: {
|
||||
home-manager.sharedModules = [
|
||||
(homeArgs: let
|
||||
direnv = lib.getExe homeArgs.config.programs.direnv.package;
|
||||
in {
|
||||
programs.direnv = {
|
||||
enable = true;
|
||||
nix-direnv.enable = true;
|
||||
enableNushellIntegration = false;
|
||||
};
|
||||
|
||||
programs.nushell.extraConfig = lib.mkAfter /* nu */ ''
|
||||
$env.config = ($env.config? | default {})
|
||||
$env.config.hooks = ($env.config.hooks? | default {})
|
||||
$env.config.hooks.pre_prompt = (
|
||||
$env.config.hooks.pre_prompt?
|
||||
| default []
|
||||
| append {||
|
||||
${direnv} export json
|
||||
| from json --strict
|
||||
| default {}
|
||||
| items {|key, value|
|
||||
let value = do (
|
||||
{
|
||||
"PATH": {
|
||||
from_string: {|s| $s | split row (char esep) | path expand --no-symlink }
|
||||
to_string: {|v| $v | path expand --no-symlink | str join (char esep) }
|
||||
}
|
||||
}
|
||||
| merge ($env.ENV_CONVERSIONS? | default {})
|
||||
| get -o $key
|
||||
| get -o from_string
|
||||
| if ($in | is-empty) { {|x| $x} } else { $in }
|
||||
) $value
|
||||
return [ $key $value ]
|
||||
}
|
||||
| into record
|
||||
| load-env
|
||||
}
|
||||
)
|
||||
'';
|
||||
})
|
||||
];
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue