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"
|
||||
];
|
||||
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
|
||||
double-quoted context, so expressions like `$HOME` are
|
||||
|
@ -329,9 +329,9 @@ in
|
|||
];
|
||||
};
|
||||
description = ''
|
||||
Extra directories to add to arbitrary PATH-like environment
|
||||
variables (e.g.: {env}`MANPATH`). The values will be concatenated
|
||||
by `:`.
|
||||
Extra directories to be prepend to arbitrary PATH-like
|
||||
environment variables (e.g.: {env}`MANPATH`). The values
|
||||
will be concatenated by `:`.
|
||||
|
||||
These directories are added to the environment variable in a
|
||||
double-quoted context, so expressions like `$HOME` are
|
||||
|
@ -581,7 +581,7 @@ in
|
|||
(mapAttrsToList
|
||||
(env: values: config.lib.shell.export
|
||||
env
|
||||
(config.lib.shell.appendToVar ":" env values))
|
||||
(config.lib.shell.prependToVar ":" env values))
|
||||
cfg.sessionSearchVariables)
|
||||
+ cfg.sessionVariablesExtra;
|
||||
};
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
{ lib }:
|
||||
|
||||
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).
|
||||
# Example:
|
||||
# appendToVar ":" "PATH" [ "$HOME/bin" "$HOME/.local/bin" ]
|
||||
# => "$PATH\${PATH:+:}$HOME/bin:$HOME/.local/bin"
|
||||
appendToVar = sep: n: v:
|
||||
"\$${n}\${${n}:+${sep}}${lib.concatStringsSep sep v}";
|
||||
# prependToVar ":" "PATH" [ "$HOME/bin" "$HOME/.local/bin" ]
|
||||
# => "$HOME/bin:$HOME/.local/bin:${PATH:+:}\$PATH"
|
||||
prependToVar = sep: n: v:
|
||||
"${lib.concatStringsSep sep v}\${${n}:+${sep}}\$${n}";
|
||||
|
||||
# Produces a Bourne shell like variable export statement.
|
||||
export = n: v: ''export ${n}="${toString v}"'';
|
||||
|
|
|
@ -10,6 +10,6 @@
|
|||
hmSessVars=home-path/etc/profile.d/hm-session-vars.sh
|
||||
assertFileExists $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
|
||||
assertFileExists $hmSessVars
|
||||
assertFileContains $hmSessVars \
|
||||
'export TEST="$TEST''${TEST:+:}bar:baz:foo"'
|
||||
'export TEST="bar:baz:foo''${TEST:+:}$TEST"'
|
||||
'';
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue