aboutsummaryrefslogtreecommitdiff
path: root/nixos/modules/config
diff options
context:
space:
mode:
Diffstat (limited to 'nixos/modules/config')
-rw-r--r--nixos/modules/config/shells-environment.nix2
-rw-r--r--nixos/modules/config/system-environment.nix76
-rw-r--r--nixos/modules/config/terminfo.nix2
-rw-r--r--nixos/modules/config/xdg/icons.nix27
4 files changed, 88 insertions, 19 deletions
diff --git a/nixos/modules/config/shells-environment.nix b/nixos/modules/config/shells-environment.nix
index 9dfc1add829..d939cbb393e 100644
--- a/nixos/modules/config/shells-environment.nix
+++ b/nixos/modules/config/shells-environment.nix
@@ -157,6 +157,8 @@ in
# terminal instead of logging out of X11).
environment.variables = config.environment.sessionVariables;
+ environment.profileRelativeEnvVars = config.environment.profileRelativeSessionVariables;
+
environment.shellAliases = mapAttrs (name: mkDefault) {
ls = "ls --color=tty";
ll = "ls -l";
diff --git a/nixos/modules/config/system-environment.nix b/nixos/modules/config/system-environment.nix
index 6011e354ece..792d1dbb38f 100644
--- a/nixos/modules/config/system-environment.nix
+++ b/nixos/modules/config/system-environment.nix
@@ -8,6 +8,11 @@ let
cfg = config.environment;
+ pamProfiles =
+ map
+ (replaceStrings ["$HOME" "$USER"] ["@{HOME}" "@{PAM_USER}"])
+ cfg.profiles;
+
in
{
@@ -18,25 +23,76 @@ in
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.
+ These variables will be set by PAM early in the login process.
+
+ The value of each session variable can be either a string or a
+ list of strings. The latter is concatenated, interspersed with
+ colon characters.
+
+ Note, due to limitations in the PAM format values may not
+ contain the <literal>"</literal> character.
+
+ Also, these variables are merged into
+ <xref linkend="opt-environment.variables"/> and it is
+ therefore not possible to use PAM style variables such as
+ <code>@{HOME}</code>.
'';
type = with types; attrsOf (either str (listOf str));
apply = mapAttrs (n: v: if isList v then concatStringsSep ":" v else v);
};
+ environment.profileRelativeSessionVariables = mkOption {
+ type = types.attrsOf (types.listOf types.str);
+ example = { PATH = [ "/bin" ]; MANPATH = [ "/man" "/share/man" ]; };
+ description = ''
+ Attribute set of environment variable used in the global
+ environment. These variables will be set by PAM early in the
+ login process.
+
+ Variable substitution is available as described in
+ <citerefentry>
+ <refentrytitle>pam_env.conf</refentrytitle>
+ <manvolnum>5</manvolnum>
+ </citerefentry>.
+
+ Each attribute maps to a list of relative paths. Each relative
+ path is appended to the each profile of
+ <option>environment.profiles</option> to form the content of
+ the corresponding environment variable.
+
+ Also, these variables are merged into
+ <xref linkend="opt-environment.profileRelativeEnvVars"/> and it is
+ therefore not possible to use PAM style variables such as
+ <code>@{HOME}</code>.
+ '';
+ };
+
};
config = {
- system.build.pamEnvironment = pkgs.writeText "pam-environment"
- ''
- ${concatStringsSep "\n" (
- (mapAttrsToList (n: v: ''${n}="${concatStringsSep ":" v}"'')
- (zipAttrsWith (const concatLists) ([ (mapAttrs (n: v: [ v ]) cfg.sessionVariables) ]))))}
- '';
+ system.build.pamEnvironment =
+ let
+ suffixedVariables =
+ flip mapAttrs cfg.profileRelativeSessionVariables (envVar: suffixes:
+ flip concatMap pamProfiles (profile:
+ map (suffix: "${profile}${suffix}") suffixes
+ )
+ );
+
+ pamVariable = n: v:
+ ''${n} DEFAULT="${concatStringsSep ":" (toList v)}"'';
+
+ pamVariables =
+ concatStringsSep "\n"
+ (mapAttrsToList pamVariable
+ (zipAttrsWith (n: concatLists)
+ [
+ (mapAttrs (n: toList) cfg.sessionVariables)
+ suffixedVariables
+ ]));
+ in
+ pkgs.writeText "pam-environment" "${pamVariables}\n";
};
diff --git a/nixos/modules/config/terminfo.nix b/nixos/modules/config/terminfo.nix
index b86ce2dbf05..1396640af67 100644
--- a/nixos/modules/config/terminfo.nix
+++ b/nixos/modules/config/terminfo.nix
@@ -12,7 +12,7 @@
source = "${config.system.path}/share/terminfo";
};
- environment.profileRelativeEnvVars = {
+ environment.profileRelativeSessionVariables = {
TERMINFO_DIRS = [ "/share/terminfo" ];
};
diff --git a/nixos/modules/config/xdg/icons.nix b/nixos/modules/config/xdg/icons.nix
index 8268a3771a0..4677ce090b0 100644
--- a/nixos/modules/config/xdg/icons.nix
+++ b/nixos/modules/config/xdg/icons.nix
@@ -7,21 +7,32 @@ with lib;
type = types.bool;
default = true;
description = ''
- Whether to install files to support the
+ Whether to install files to support the
<link xlink:href="https://specifications.freedesktop.org/icon-theme-spec/icon-theme-spec-latest.html">XDG Icon Theme specification</link>.
'';
};
};
config = mkIf config.xdg.icons.enable {
- environment.pathsToLink = [
- "/share/icons"
- "/share/pixmaps"
+ environment.pathsToLink = [
+ "/share/icons"
+ "/share/pixmaps"
+ ];
+
+ # libXcursor looks for cursors in XCURSOR_PATH
+ # it mostly follows the spec for icons
+ # See: https://www.x.org/releases/current/doc/man/man3/Xcursor.3.xhtml Themes
+
+ # These are preferred so they come first in the list
+ environment.sessionVariables.XCURSOR_PATH = [
+ "$HOME/.icons"
+ "$HOME/.local/share/icons"
+ ];
+
+ environment.profileRelativeSessionVariables.XCURSOR_PATH = [
+ "/share/icons"
+ "/share/pixmaps"
];
-
- environment.profileRelativeEnvVars = {
- XCURSOR_PATH = [ "/share/icons" ];
- };
};
}