Skip to content

Commit 7a7398c

Browse files
committed
yubikey-touch-detector: move from programs to services, add packages
Since yubikey-touch-detector is more of a service running in the background, I propose to move to the services section under misc. I also added a package option to enable custom packages to be run instead of the default one.
1 parent 3611af4 commit 7a7398c

File tree

3 files changed

+72
-16
lines changed

3 files changed

+72
-16
lines changed

nixos/modules/module-list.nix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -870,6 +870,7 @@
870870
./services/misc/weechat.nix
871871
./services/misc/workout-tracker.nix
872872
./services/misc/xmrig.nix
873+
./services/misc/yubikey-touch-detector.nix
873874
./services/misc/zoneminder.nix
874875
./services/misc/zookeeper.nix
875876
./services/monitoring/alerta.nix

nixos/modules/programs/yubikey-touch-detector.nix

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -43,21 +43,13 @@ in
4343
};
4444

4545
config = lib.mkIf cfg.enable {
46-
systemd.packages = [ pkgs.yubikey-touch-detector ];
47-
48-
systemd.user.services.yubikey-touch-detector = {
49-
path = [ pkgs.gnupg ];
50-
51-
environment = {
52-
YUBIKEY_TOUCH_DETECTOR_LIBNOTIFY = builtins.toString cfg.libnotify;
53-
YUBIKEY_TOUCH_DETECTOR_NOSOCKET = builtins.toString (!cfg.unixSocket);
54-
YUBIKEY_TOUCH_DETECTOR_VERBOSE = builtins.toString cfg.verbose;
55-
};
56-
57-
wantedBy = [ "graphical-session.target" ];
58-
};
59-
systemd.user.sockets.yubikey-touch-detector = {
60-
wantedBy = [ "sockets.target" ];
61-
};
46+
services.yubikey-touch-detector = cfg;
47+
48+
warnings = [
49+
''
50+
The module programs.yubikey-touch-detector is deprecated.
51+
Please use services.yubikey-touch-detector instead.
52+
''
53+
];
6254
};
6355
}
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
{
2+
config,
3+
lib,
4+
pkgs,
5+
...
6+
}:
7+
let
8+
inherit (lib) types;
9+
cfg = config.services.yubikey-touch-detector;
10+
in
11+
{
12+
options.services.yubikey-touch-detector = {
13+
14+
enable = lib.mkEnableOption "yubikey-touch-detector";
15+
16+
package = lib.mkPackageOption pkgs "yubikey-touch-detector" { };
17+
18+
libnotify = lib.mkOption {
19+
# This used to be true previously and using libnotify would be a sane default.
20+
default = true;
21+
type = types.bool;
22+
description = ''
23+
If set to true, yubikey-touch-detctor will send notifications using libnotify
24+
'';
25+
};
26+
27+
unixSocket = lib.mkOption {
28+
default = true;
29+
type = types.bool;
30+
description = ''
31+
If set to true, yubikey-touch-detector will send notifications to a unix socket
32+
'';
33+
};
34+
35+
verbose = lib.mkOption {
36+
default = false;
37+
type = types.bool;
38+
description = ''
39+
Enables verbose logging
40+
'';
41+
};
42+
43+
};
44+
45+
config = lib.mkIf cfg.enable {
46+
systemd.packages = [ cfg.package ];
47+
48+
systemd.user.services.yubikey-touch-detector = {
49+
path = [ pkgs.gnupg ];
50+
51+
environment = {
52+
YUBIKEY_TOUCH_DETECTOR_LIBNOTIFY = builtins.toString cfg.libnotify;
53+
YUBIKEY_TOUCH_DETECTOR_NOSOCKET = builtins.toString (!cfg.unixSocket);
54+
YUBIKEY_TOUCH_DETECTOR_VERBOSE = builtins.toString cfg.verbose;
55+
};
56+
57+
wantedBy = [ "graphical-session.target" ];
58+
};
59+
systemd.user.sockets.yubikey-touch-detector = {
60+
wantedBy = [ "sockets.target" ];
61+
};
62+
};
63+
}

0 commit comments

Comments
 (0)