2014-06-10 11:07:10 +00:00
|
|
|
# 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 = {
|
|
|
|
|
2014-06-13 15:56:46 +00:00
|
|
|
environment.sessionVariables = mkOption {
|
2014-06-10 11:07:10 +00:00
|
|
|
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.
|
|
|
|
'';
|
2016-11-04 04:33:59 +00:00
|
|
|
type = with types; attrsOf (either str (listOf str));
|
2014-06-10 11:07:10 +00:00
|
|
|
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}"'')
|
2014-06-13 15:56:46 +00:00
|
|
|
(zipAttrsWith (const concatLists) ([ (mapAttrs (n: v: [ v ]) cfg.sessionVariables) ]))))}
|
2014-06-10 11:07:10 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|