mirror of
https://github.com/nix-community/home-manager
synced 2024-06-01 04:23:34 +02:00
20 lines
724 B
Nix
20 lines
724 B
Nix
{ lib }:
|
|
|
|
rec {
|
|
# Produces a Bourne shell like statement that prepend new values to
|
|
# an possibly existing variable, using sep(ator).
|
|
# 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}"'';
|
|
|
|
# Given an attribute set containing shell variable names and their
|
|
# assignment, this function produces a string containing an export
|
|
# statement for each set entry.
|
|
exportAll = vars: lib.concatStringsSep "\n" (lib.mapAttrsToList export vars);
|
|
}
|