mirror of
https://github.com/nix-community/home-manager.git
synced 2025-12-24 09:50:58 +01:00
home-environment: add home.sessionSearchVariables
This commit introduces `home.sessionSearchVariables` option, that is created to be a "generic" version of `home.sessionPath` for any environment variables that is similar to PATH (e.g.: MANPATH). This allows composition of those variables between multiple modules, avoiding issues like this one: https://github.com/nix-community/home-manager/pull/4579/files#r1364374048 This commit also reimplements `home.sessionPath` as terms of `home.sessionSearchVariables`, to reduce code duplication and show that the code is correct. The behavior is to prepend the new search paths. This will allow the user to override the defaults easily by setting it later in the configuration.
This commit is contained in:
parent
07f505f91e
commit
277eea1cc7
5 changed files with 59 additions and 7 deletions
|
|
@ -17,6 +17,14 @@ let
|
|||
};
|
||||
|
||||
in rec {
|
||||
# Produces a Bourne shell like statement that prepend new values to
|
||||
# an possibly existing variable, using sep(arator).
|
||||
# Example:
|
||||
# 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}"'';
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue