-
-
Notifications
You must be signed in to change notification settings - Fork 15.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge #2692: Use pam_env to properly setup system-wide env
(cherry picked from commit 18a0cdd)
- Loading branch information
Showing
10 changed files
with
73 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
# This module defines a system-wide environment that will be | ||
# initialised by pam_env (that is, not only in shells). | ||
{ config, lib, pkgs, ... }: | ||
|
||
with lib; | ||
|
||
let | ||
|
||
cfg = config.environment; | ||
|
||
in | ||
|
||
{ | ||
|
||
options = { | ||
|
||
environment.systemVariables = mkOption { | ||
default = {}; | ||
description = '' | ||
A set of environment variables used in the global environment. | ||
These variables will be set by PAM. | ||
The value of each variable can be either a string or a list of | ||
strings. The latter is concatenated, interspersed with colon | ||
characters. | ||
''; | ||
type = types.attrsOf (mkOptionType { | ||
name = "a string or a list of strings"; | ||
merge = loc: defs: | ||
let | ||
defs' = filterOverrides defs; | ||
res = (head defs').value; | ||
in | ||
if isList res then concatLists (getValues defs') | ||
else if lessThan 1 (length defs') then | ||
throw "The option `${showOption loc}' is defined multiple times, in ${showFiles (getFiles defs)}." | ||
else if !isString res then | ||
throw "The option `${showOption loc}' does not have a string value, in ${showFiles (getFiles defs)}." | ||
else res; | ||
}); | ||
apply = mapAttrs (n: v: if isList v then concatStringsSep ":" v else v); | ||
}; | ||
|
||
}; | ||
|
||
config = { | ||
|
||
system.build.pamEnvironment = pkgs.writeText "pam-environment" | ||
'' | ||
${concatStringsSep "\n" ( | ||
(mapAttrsToList (n: v: ''${n}="${concatStringsSep ":" v}"'') | ||
(zipAttrsWith (const concatLists) ([ (mapAttrs (n: v: [ v ]) cfg.systemVariables) ]))))} | ||
''; | ||
|
||
}; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters