-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathyubikey.nix
66 lines (61 loc) · 1.59 KB
/
yubikey.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
{
lib,
config,
pkgs,
...
}: {
options = {
program.yubikey = {
enable = lib.mkEnableOption "Enable YubiKey authentication";
lock-on-remove = lib.mkEnableOption "Lock the session when the YubiKey is removed";
notify = lib.mkEnableOption "Notify when the YubiKey is touched";
};
};
config = lib.mkMerge [
(lib.mkIf config.program.yubikey.enable {
environment.systemPackages = with pkgs; [
yubioath-flutter
yubikey-manager
pam_u2f
];
# Only have to be connected to the notebook
#security.pam.services = {
# login.u2fAuth = true;
# sudo.u2fAuth = true;
#};
security.pam.yubico = {
enable = true;
debug = false;
mode = "challenge-response";
control = "sufficient";
#! id = [ "1234567890" ];
#! YubiKey ID is stored in SOPS
#! and is set in the module configuration
#! file ./sops/sops.nix
};
services.pcscd = {
enable = true;
};
programs.gnupg.agent = {
enable = true;
enableSSHSupport = true;
};
})
(lib.mkIf config.program.yubikey.notify {
programs.yubikey-touch-detector = {
enable = true;
libnotify = true;
};
})
(lib.mkIf config.program.yubikey.lock-on-remove {
services.udev.extraRules = ''
ACTION=="remove",\
ENV{ID_BUS}=="usb",\
ENV{ID_MODEL_ID}=="0407",\
ENV{ID_VENDOR_ID}=="1050",\
ENV{ID_VENDOR}=="Yubico",\
RUN+="${pkgs.systemd}/bin/loginctl lock-sessions"
'';
})
];
}