|
10 | 10 | in {
|
11 | 11 | enable = mkEnableOption "Enable YubiAuth";
|
12 | 12 |
|
| 13 | + installGUIApps = mkOption { |
| 14 | + type = bool; |
| 15 | + default = true; |
| 16 | + description = "Install GUI applications for YubiKey management"; |
| 17 | + }; |
| 18 | + |
| 19 | + notify = mkOption { |
| 20 | + type = bool; |
| 21 | + default = true; |
| 22 | + description = |
| 23 | + "Enable desktop notifications when yubikey auth requires user interaction"; |
| 24 | + }; |
| 25 | + |
13 | 26 | login = mkOption {
|
14 | 27 | type = bool;
|
15 | 28 | default = true;
|
|
36 | 49 |
|
37 | 50 | config = mkIf cfg.enable {
|
38 | 51 | # yibikey required packages
|
39 |
| - environment.systemPackages = with pkgs; [ |
40 |
| - yubikey-personalization |
41 |
| - yubikey-manager |
42 |
| - yubico-pam |
43 |
| - ]; |
| 52 | + environment.systemPackages = with pkgs; |
| 53 | + [ yubikey-manager yubikey-personalization yubico-pam ] |
| 54 | + ++ lib.optionals cfg.installGUIApps [ |
| 55 | + yubikey-manager-qt |
| 56 | + yubikey-personalization-gui |
| 57 | + yubioath-flutter |
| 58 | + ]; |
44 | 59 |
|
45 | 60 | # enable smartcard support
|
46 | 61 | hardware.gpgSmartcards.enable = true;
|
|
68 | 83 | environment.etc."u2f-mappings".text =
|
69 | 84 | mkIf (builtins.length cfg.mappings > 0)
|
70 | 85 | (lib.concatStringsSep "\n" cfg.mappings);
|
| 86 | + |
| 87 | + # enable desktop notifications for yubikey auth |
| 88 | + systemd.user = let |
| 89 | + serviceName = "yubikey-touch-detector"; |
| 90 | + serviceConf = pkgs.writeText "service.conf" '' |
| 91 | + # show desktop notifications using libnotify |
| 92 | + YUBIKEY_TOUCH_DETECTOR_LIBNOTIFY=true |
| 93 | + ''; |
| 94 | + in mkIf cfg.notify { |
| 95 | + sockets.${serviceName} = { |
| 96 | + description = |
| 97 | + "Unix socket activation for YubiKey touch detector service"; |
| 98 | + socketConfig = { |
| 99 | + ListenStream = "%t/${serviceName}.socket"; |
| 100 | + RemoveOnStop = true; |
| 101 | + }; |
| 102 | + wantedBy = [ "sockets.target" ]; |
| 103 | + }; |
| 104 | + services.${serviceName} = { |
| 105 | + description = "Detects when your YubiKey is waiting for a touch"; |
| 106 | + requires = [ "${serviceName}.socket" ]; |
| 107 | + serviceConfig = { |
| 108 | + ExecStart = |
| 109 | + "${pkgs.yubikey-touch-detector}/bin/yubikey-touch-detector"; |
| 110 | + EnvironmentFile = "${serviceConf}"; |
| 111 | + }; |
| 112 | + requiredBy = [ "default.target" ]; |
| 113 | + partOf = [ "${serviceName}.socket" ]; |
| 114 | + }; |
| 115 | + }; |
71 | 116 | };
|
72 | 117 | }
|
0 commit comments