diff options
author | worldofpeace <worldofpeace@protonmail.ch> | 2019-10-02 01:20:28 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-10-02 01:20:28 +0000 |
commit | 49bc1bf44a0e7e1d4eea38d150c4af7cb29b38c4 (patch) | |
tree | 2effd05a1afc958ad32aede0362fd90943f9bd17 /nixos | |
parent | 5ddf3512bacbd139f9caba6c232f51069d64e650 (diff) | |
parent | d8b9742deb3994018d94fc550e777ea684baca6e (diff) |
Merge pull request #70137 from michaelpj/fix-pam-variable-subst
nixos/system-environment: fix variable substitution
Diffstat (limited to 'nixos')
-rw-r--r-- | nixos/modules/config/system-environment.nix | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/nixos/modules/config/system-environment.nix b/nixos/modules/config/system-environment.nix index 792d1dbb38f68..4b663ebf85a49 100644 --- a/nixos/modules/config/system-environment.nix +++ b/nixos/modules/config/system-environment.nix @@ -8,11 +8,6 @@ let cfg = config.environment; - pamProfiles = - map - (replaceStrings ["$HOME" "$USER"] ["@{HOME}" "@{PAM_USER}"]) - cfg.profiles; - in { @@ -75,13 +70,20 @@ in let suffixedVariables = flip mapAttrs cfg.profileRelativeSessionVariables (envVar: suffixes: - flip concatMap pamProfiles (profile: + flip concatMap cfg.profiles (profile: map (suffix: "${profile}${suffix}") suffixes ) ); + # We're trying to use the same syntax for PAM variables and env variables. + # That means we need to map the env variables that people might use to their + # equivalent PAM variable. + # Note: PAM_USER is a PAM_ITEM, HOME is an environment variable, they have + # different syntax. + replaceEnvVars = replaceStrings ["$HOME" "$USER"] ["\${HOME}" "@{PAM_USER}"]; + pamVariable = n: v: - ''${n} DEFAULT="${concatStringsSep ":" (toList v)}"''; + ''${n} DEFAULT="${concatStringsSep ":" (map replaceEnvVars (toList v))}"''; pamVariables = concatStringsSep "\n" |