2017-01-16 22:54:45 +00:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
|
2021-11-22 11:10:11 +00:00
|
|
|
cfg = config.pam;
|
2018-01-04 15:11:23 +00:00
|
|
|
|
2020-02-01 23:39:17 +00:00
|
|
|
in {
|
2021-11-22 11:10:11 +00:00
|
|
|
meta.maintainers = with maintainers; [ rycee veehaitch ];
|
2017-09-26 21:40:31 +00:00
|
|
|
|
2018-01-04 15:11:23 +00:00
|
|
|
options = {
|
|
|
|
pam.sessionVariables = mkOption {
|
2020-02-01 23:39:17 +00:00
|
|
|
default = { };
|
2019-04-26 22:21:18 +00:00
|
|
|
type = types.attrs;
|
2018-01-04 15:11:23 +00:00
|
|
|
example = { EDITOR = "vim"; };
|
2023-06-30 23:30:13 +00:00
|
|
|
description = lib.mdDoc ''
|
2018-01-04 15:11:23 +00:00
|
|
|
Environment variables that will be set for the PAM session.
|
|
|
|
The variable values must be as described in
|
2023-06-30 23:30:13 +00:00
|
|
|
{manpage}`pam_env.conf(5)`.
|
|
|
|
|
2020-12-31 13:29:35 +00:00
|
|
|
Note, this option will become deprecated in the future and its use is
|
|
|
|
therefore discouraged.
|
2018-01-04 15:11:23 +00:00
|
|
|
'';
|
|
|
|
};
|
2017-01-16 22:54:45 +00:00
|
|
|
|
2021-11-22 11:10:11 +00: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 = [ ];
|
2023-06-30 23:30:13 +00:00
|
|
|
description = lib.mdDoc ''
|
2021-11-22 11:10:11 +00:00
|
|
|
List of authorized YubiKey token IDs. Refer to
|
2023-06-30 23:30:13 +00:00
|
|
|
<https://developers.yubico.com/yubico-pam>
|
2021-11-22 11:10:11 +00:00
|
|
|
for details on how to obtain the token ID of a YubiKey.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
path = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = ".yubico/authorized_yubikeys";
|
2023-06-30 23:30:13 +00:00
|
|
|
description = lib.mdDoc ''
|
2021-11-22 11:10:11 +00:00
|
|
|
File path to write the authorized YubiKeys,
|
2023-06-30 23:30:13 +00:00
|
|
|
relative to {env}`HOME`.
|
2021-11-22 11:10:11 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
2017-01-16 22:54:45 +00:00
|
|
|
};
|
2021-11-22 11:10:11 +00:00
|
|
|
|
|
|
|
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);
|
|
|
|
})
|
|
|
|
];
|
2017-01-16 22:54:45 +00:00
|
|
|
}
|