mirror of
https://github.com/nix-community/home-manager.git
synced 2024-12-14 11:57:55 +00:00
nushell: add envVars attribute (#3930)
This commit is contained in:
parent
0e4c33d760
commit
788777b536
3 changed files with 19 additions and 1 deletions
|
@ -121,6 +121,15 @@ in {
|
|||
this option) to command strings or directly to build outputs.
|
||||
'';
|
||||
};
|
||||
|
||||
environmentVariables = mkOption {
|
||||
type = types.attrsOf types.str;
|
||||
default = { };
|
||||
example = { FOO = "BAR"; };
|
||||
description = ''
|
||||
An attribute set that maps an environment variable to a shell interpreted string.
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
|
@ -141,10 +150,15 @@ in {
|
|||
];
|
||||
})
|
||||
|
||||
(mkIf (cfg.envFile != null || cfg.extraEnv != "") {
|
||||
(let
|
||||
envVarsStr = concatStringsSep "\n"
|
||||
(mapAttrsToList (k: v: "let-env ${k} = ${v}")
|
||||
cfg.environmentVariables);
|
||||
in mkIf (cfg.envFile != null || cfg.extraEnv != "" || envVarsStr != "") {
|
||||
"${configDir}/env.nu".text = mkMerge [
|
||||
(mkIf (cfg.envFile != null) cfg.envFile.text)
|
||||
cfg.extraEnv
|
||||
envVarsStr
|
||||
];
|
||||
})
|
||||
];
|
||||
|
|
|
@ -1,2 +1,4 @@
|
|||
let-env FOO = 'BAR'
|
||||
|
||||
|
||||
let-env BAR = $'(echo BAZ)'
|
|
@ -20,6 +20,8 @@
|
|||
"lsname" = "(ls | get name)";
|
||||
"ll" = "ls -a";
|
||||
};
|
||||
|
||||
environmentVariables = { BAR = "$'(echo BAZ)'"; };
|
||||
};
|
||||
|
||||
test.stubs.nushell = { };
|
||||
|
|
Loading…
Reference in a new issue