fork/home-manager
git clone https://git.julia.blue/fork/home-manager
75790441
master
1{ config , lib , pkgs , ...} : 2 3with lib ; 4 5let 6 7cfg = config . pam ; 8 9in { 10meta . maintainers = with maintainers ; [ rycee veehaitch ]; 11 12options = { 13pam . sessionVariables = mkOption { 14default = { }; 15type = types . attrs ; 16example = { EDITOR = "vim" ; }; 17description = '' 18Environment variables that will be set for the PAM session. 19The variable values must be as described in 20{manpage}`pam_env.conf(5)`. 21 22Note, this option will become deprecated in the future and its use is 23therefore discouraged. 24'' ; 25}; 26 27pam . yubico . authorizedYubiKeys = { 28ids = mkOption { 29type = with types ; 30let 31yubiKeyId = addCheck str ( s :stringLength s == 12 ) // { 32name = "yubiKeyId" ; 33description = "string of length 12" ; 34}; 35in listOf yubiKeyId ; 36default = [ ]; 37description = '' 38List of authorized YubiKey token IDs. Refer to 39<https://developers.yubico.com/yubico-pam> 40for details on how to obtain the token ID of a YubiKey. 41'' ; 42}; 43 44path = mkOption { 45type = types . str ; 46default = ".yubico/authorized_yubikeys" ; 47description = '' 48File path to write the authorized YubiKeys, 49relative to {env}`HOME`. 50'' ; 51}; 52}; 53}; 54 55config = mkMerge [ 56( mkIf ( cfg . sessionVariables != { }) { 57home . file . ".pam_environment" . text = concatStringsSep "\n" 58( mapAttrsToList ( n :v :'' ${ n } OVERRIDE=" ${ toString v } "'' ) 59cfg . sessionVariables ) + "\n" ; 60}) 61 62( mkIf ( cfg . yubico . authorizedYubiKeys . ids != [ ]) { 63home . file .${ cfg . yubico . authorizedYubiKeys . path }. text = 64concatStringsSep ":" 65([ config . home . username ] ++ cfg . yubico . authorizedYubiKeys . ids ); 66}) 67]; 68}