-
-
Notifications
You must be signed in to change notification settings - Fork 13.3k
/
evdevremapkeys.nix
59 lines (55 loc) · 1.58 KB
/
evdevremapkeys.nix
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
{ config, lib, pkgs, ... }:
with lib;
let
format = pkgs.formats.yaml { };
cfg = config.services.evdevremapkeys;
in
{
options.services.evdevremapkeys = {
enable = mkEnableOption ''evdevremapkeys, a daemon to remap events on linux input devices'';
settings = mkOption {
type = format.type;
default = { };
description = ''
config.yaml for evdevremapkeys
'';
};
};
config = mkIf cfg.enable {
boot.kernelModules = [ "uinput" ];
services.udev.extraRules = ''
KERNEL=="uinput", MODE="0660", GROUP="input"
'';
users.groups.evdevremapkeys = { };
users.users.evdevremapkeys = {
description = "evdevremapkeys service user";
group = "evdevremapkeys";
extraGroups = [ "input" ];
isSystemUser = true;
};
systemd.services.evdevremapkeys = {
description = "evdevremapkeys";
wantedBy = [ "multi-user.target" ];
serviceConfig =
let
config = format.generate "config.yaml" cfg.settings;
in
{
ExecStart = "${pkgs.evdevremapkeys}/bin/evdevremapkeys --config-file ${config}";
User = "evdevremapkeys";
Group = "evdevremapkeys";
StateDirectory = "evdevremapkeys";
Restart = "always";
LockPersonality = true;
MemoryDenyWriteExecute = true;
NoNewPrivileges = true;
PrivateNetwork = true;
PrivateTmp = true;
ProtectControlGroups = true;
ProtectHome = true;
ProtectKernelTunables = true;
ProtectSystem = true;
};
};
};
}