summaryrefslogtreecommitdiff
path: root/config/yubikey.nix
blob: d10bb5767cb324f8af49158e442ec1aa4183f4c3 (plain)
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
{ config, lib, pkgs, ... }:
let
  yubikey-pkgs = with pkgs; [
    ccid
    libu2f-host
    libusb
    rng_tools
    yubikey-manager
    yubikey-personalization
    gnupg
    pinentry
  ];
in
{
  services.pcscd.enable = true;
  services.udev.packages = with pkgs; [
    libu2f-host
    yubikey-personalization
  ];
  services.gnome3.gnome-keyring.enable = lib.mkForce false;

  programs.gnupg.agent = {
    enable = true;
    enableSSHSupport = true;
  };
  # Use GPG agent instead.
  programs.ssh.startAgent = lib.mkDefault false;

  environment = {
    systemPackages = yubikey-pkgs;
  };

  security.sudo.extraRules = [
    {
      groups = [ "wheel" ];
      commands = [ { command = "${pkgs.systemd}/bin/systemctl restart pcscd"; options = [ "NOPASSWD" ]; } ];
    }
  ];

  systemd.user.services.restart-pcscd = {
    description = "Redshift colour temperature adjuster";
    wantedBy = [ "graphical-session.target" ];
    partOf = [ "graphical-session.target" ];
    serviceConfig = {
      ExecStart = ''
        sudo systemctl restart pcscd
      '';
      Type = "oneshot";
    };
  };
}