1{
2 config,
3 lib,
4 pkgs,
5 ...
6}:
7let
8 cfg = config.services.logkeys;
9in
10{
11 options.services.logkeys = {
12 enable = lib.mkEnableOption "logkeys, a keylogger service";
13
14 device = lib.mkOption {
15 description = "Use the given device as keyboard input event device instead of /dev/input/eventX default.";
16 default = null;
17 type = lib.types.nullOr lib.types.str;
18 example = "/dev/input/event15";
19 };
20 };
21
22 config = lib.mkIf cfg.enable {
23 systemd.services.logkeys = {
24 description = "LogKeys Keylogger Daemon";
25 wantedBy = [ "multi-user.target" ];
26 serviceConfig = {
27 ExecStart = "${pkgs.logkeys}/bin/logkeys -s${
28 lib.optionalString (cfg.device != null) " -d ${cfg.device}"
29 }";
30 ExecStop = "${pkgs.logkeys}/bin/logkeys -k";
31 Type = "forking";
32 };
33 };
34 };
35}