1
0
mirror of https://github.com/nix-community/home-manager synced 2024-06-26 08:28:30 +02:00
home-manager/modules/misc/pam.nix

72 lines
1.9 KiB
Nix
Raw Normal View History

{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.pam;
2018-01-04 16:11:23 +01:00
2020-02-02 00:39:17 +01:00
in {
meta.maintainers = with maintainers; [ rycee veehaitch ];
2018-01-04 16:11:23 +01:00
options = {
pam.sessionVariables = mkOption {
2020-02-02 00:39:17 +01:00
default = { };
type = types.attrs;
2018-01-04 16:11:23 +01:00
example = { EDITOR = "vim"; };
description = ''
Environment variables that will be set for the PAM session.
The variable values must be as described in
<citerefentry>
<refentrytitle>pam_env.conf</refentrytitle>
<manvolnum>5</manvolnum>
</citerefentry>.
</para><para>
Note, this option will become deprecated in the future and its use is
therefore discouraged.
2018-01-04 16:11:23 +01:00
'';
};
pam.yubico.authorizedYubiKeys = {
ids = mkOption {
type = with types;
let
yubiKeyId = addCheck str (s: stringLength s == 12) // {
name = "yubiKeyId";
description = "string of length 12";
};
in listOf yubiKeyId;
default = [ ];
description = ''
List of authorized YubiKey token IDs. Refer to
<link xlink:href="https://developers.yubico.com/yubico-pam"/>
for details on how to obtain the token ID of a YubiKey.
'';
};
path = mkOption {
type = types.str;
default = ".yubico/authorized_yubikeys";
description = ''
File path to write the authorized YubiKeys,
relative to <envar>HOME</envar>.
'';
};
};
};
config = mkMerge [
(mkIf (cfg.sessionVariables != { }) {
home.file.".pam_environment".text = concatStringsSep "\n"
(mapAttrsToList (n: v: ''${n} OVERRIDE="${toString v}"'')
cfg.sessionVariables) + "\n";
})
(mkIf (cfg.yubico.authorizedYubiKeys.ids != [ ]) {
home.file.${cfg.yubico.authorizedYubiKeys.path}.text =
concatStringsSep ":"
([ config.home.username ] ++ cfg.yubico.authorizedYubiKeys.ids);
})
];
}