summaryrefslogtreecommitdiffstats
path: root/nixos/modules/programs/yubikey-touch-detector.nix
blob: 4c9da9133bd67c76811323b327e62a8c335819f6 (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
52
53
54
55
56
57
58
59
60
61
62
63
64
{
  config,
  lib,
  pkgs,
  ...
}:
let
  inherit (lib) types;
  cfg = config.programs.yubikey-touch-detector;
in
{
  options = {
    programs.yubikey-touch-detector = {

      enable = lib.mkEnableOption "yubikey-touch-detector";

      libnotify = lib.mkOption {
        # This used to be true previously and using libnotify would be a sane default.
        default = true;
        type = types.bool;
        description = ''
          If set to true, yubikey-touch-detctor will send notifications using libnotify
        '';
      };

      unixSocket = lib.mkOption {
        default = true;
        type = types.bool;
        description = ''
          If set to true, yubikey-touch-detector will send notifications to a unix socket
        '';
      };

      verbose = lib.mkOption {
        default = false;
        type = types.bool;
        description = ''
          Enables verbose logging
        '';
      };

    };
  };

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

    systemd.user.services.yubikey-touch-detector = {
      path = [ pkgs.gnupg ];

      environment = {
        YUBIKEY_TOUCH_DETECTOR_LIBNOTIFY = toString cfg.libnotify;
        YUBIKEY_TOUCH_DETECTOR_NOSOCKET = toString (!cfg.unixSocket);
        YUBIKEY_TOUCH_DETECTOR_VERBOSE = toString cfg.verbose;
      };

      wantedBy = [ "graphical-session.target" ];
      partOf = [ "graphical-session.target" ];
    };
    systemd.user.sockets.yubikey-touch-detector = {
      wantedBy = [ "sockets.target" ];
    };
  };
}