about summary refs log tree commit diff
path: root/home/yubikey/default.nix
blob: d4b73d5368f69d7c2cd04c7ef958e58c000c1419 (plain) (blame)
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
{ pkgs, config, lib, ... }:
let cfg = config.my.home.yubikey;
in
{
  options.my.home.yubikey = with lib; {
    enable = mkEnableOption "yubikey tooling";
  };

  config = lib.mkIf cfg.enable {
    home.packages = with pkgs; [ yubikey-manager yubikey-touch-detector ];

    systemd.user.sockets.yubikey-touch-detector = {
      Unit.Description = "Unix socket activation for YubiKey touch detector service";
      Socket = {
        ListenStream = "%t/yubikey-touch-detector.socket";
        RemoveOnStop = true;
      };
      Install.WantedBy = [ "sockets.target" ];
    };

    systemd.user.services.yubikey-touch-detector = {
      Unit = {
        Description = "Detects when your YubiKey is waiting for a touch";
        Requires = "yubikey-touch-detector.socket";
      };
      Service = {
        ExecStart = "${pkgs.yubikey-touch-detector}/bin/yubikey-touch-detector --libnotify";
        EnvironmentFile = "-%E/yubikey-touch-detector/service.conf";
      };
      Install = {
        Also = "yubikey-touch-detector.socket";
        WantedBy = [ "default.target" ];
      };
    };
  };
}