Skip to content

Commit eb7038d

Browse files
committed
add prompt notification for yubikey auth, add install gui apps option
1 parent 3510400 commit eb7038d

File tree

1 file changed

+50
-5
lines changed

1 file changed

+50
-5
lines changed

modules/nixos/base/yubikey.nix

Lines changed: 50 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,19 @@ in {
1010
in {
1111
enable = mkEnableOption "Enable YubiAuth";
1212

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+
1326
login = mkOption {
1427
type = bool;
1528
default = true;
@@ -36,11 +49,13 @@ in {
3649

3750
config = mkIf cfg.enable {
3851
# 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+
];
4459

4560
# enable smartcard support
4661
hardware.gpgSmartcards.enable = true;
@@ -68,5 +83,35 @@ in {
6883
environment.etc."u2f-mappings".text =
6984
mkIf (builtins.length cfg.mappings > 0)
7085
(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+
};
71116
};
72117
}

0 commit comments

Comments
 (0)