mirror of
https://github.com/nix-community/home-manager
synced 2024-11-15 23:59:45 +01:00
home-environment: prepend instead of append
This commit is contained in:
parent
664086fa4c
commit
0b25ac41ee
4 changed files with 12 additions and 12 deletions
|
@ -309,7 +309,7 @@ in
|
||||||
".git/safe/../../bin"
|
".git/safe/../../bin"
|
||||||
];
|
];
|
||||||
description = ''
|
description = ''
|
||||||
Extra directories to add to {env}`PATH`.
|
Extra directories to be prepend to {env}`PATH`.
|
||||||
|
|
||||||
These directories are added to the {env}`PATH` variable in a
|
These directories are added to the {env}`PATH` variable in a
|
||||||
double-quoted context, so expressions like `$HOME` are
|
double-quoted context, so expressions like `$HOME` are
|
||||||
|
@ -329,9 +329,9 @@ in
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
description = ''
|
description = ''
|
||||||
Extra directories to add to arbitrary PATH-like environment
|
Extra directories to be prepend to arbitrary PATH-like
|
||||||
variables (e.g.: {env}`MANPATH`). The values will be concatenated
|
environment variables (e.g.: {env}`MANPATH`). The values
|
||||||
by `:`.
|
will be concatenated by `:`.
|
||||||
|
|
||||||
These directories are added to the environment variable in a
|
These directories are added to the environment variable in a
|
||||||
double-quoted context, so expressions like `$HOME` are
|
double-quoted context, so expressions like `$HOME` are
|
||||||
|
@ -581,7 +581,7 @@ in
|
||||||
(mapAttrsToList
|
(mapAttrsToList
|
||||||
(env: values: config.lib.shell.export
|
(env: values: config.lib.shell.export
|
||||||
env
|
env
|
||||||
(config.lib.shell.appendToVar ":" env values))
|
(config.lib.shell.prependToVar ":" env values))
|
||||||
cfg.sessionSearchVariables)
|
cfg.sessionSearchVariables)
|
||||||
+ cfg.sessionVariablesExtra;
|
+ cfg.sessionVariablesExtra;
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
{ lib }:
|
{ lib }:
|
||||||
|
|
||||||
rec {
|
rec {
|
||||||
# Produces a Bourne shell like statement that appends new values to
|
# Produces a Bourne shell like statement that prepend new values to
|
||||||
# an possibly existing variable, using sep(ator).
|
# an possibly existing variable, using sep(ator).
|
||||||
# Example:
|
# Example:
|
||||||
# appendToVar ":" "PATH" [ "$HOME/bin" "$HOME/.local/bin" ]
|
# prependToVar ":" "PATH" [ "$HOME/bin" "$HOME/.local/bin" ]
|
||||||
# => "$PATH\${PATH:+:}$HOME/bin:$HOME/.local/bin"
|
# => "$HOME/bin:$HOME/.local/bin:${PATH:+:}\$PATH"
|
||||||
appendToVar = sep: n: v:
|
prependToVar = sep: n: v:
|
||||||
"\$${n}\${${n}:+${sep}}${lib.concatStringsSep sep v}";
|
"${lib.concatStringsSep sep v}\${${n}:+${sep}}\$${n}";
|
||||||
|
|
||||||
# Produces a Bourne shell like variable export statement.
|
# Produces a Bourne shell like variable export statement.
|
||||||
export = n: v: ''export ${n}="${toString v}"'';
|
export = n: v: ''export ${n}="${toString v}"'';
|
||||||
|
|
|
@ -10,6 +10,6 @@
|
||||||
hmSessVars=home-path/etc/profile.d/hm-session-vars.sh
|
hmSessVars=home-path/etc/profile.d/hm-session-vars.sh
|
||||||
assertFileExists $hmSessVars
|
assertFileExists $hmSessVars
|
||||||
assertFileContains $hmSessVars \
|
assertFileContains $hmSessVars \
|
||||||
'export PATH="$PATH''${PATH:+:}bar:baz:foo"'
|
'export PATH="bar:baz:foo''${PATH:+:}$PATH"'
|
||||||
'';
|
'';
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,6 @@
|
||||||
hmSessVars=home-path/etc/profile.d/hm-session-vars.sh
|
hmSessVars=home-path/etc/profile.d/hm-session-vars.sh
|
||||||
assertFileExists $hmSessVars
|
assertFileExists $hmSessVars
|
||||||
assertFileContains $hmSessVars \
|
assertFileContains $hmSessVars \
|
||||||
'export TEST="$TEST''${TEST:+:}bar:baz:foo"'
|
'export TEST="bar:baz:foo''${TEST:+:}$TEST"'
|
||||||
'';
|
'';
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue