tangled
alpha
login
or
join now
pyrox.dev
/
nixpkgs
0
fork
atom
lol
0
fork
atom
overview
issues
pulls
pipelines
nixos/kanata: add default value, doc and warning for devices
Lin Jian
2 years ago
c5ba4c68
ad6a4051
+15
-1
1 changed file
expand all
collapse all
unified
split
nixos
modules
services
hardware
kanata.nix
+15
-1
nixos/modules/services/hardware/kanata.nix
···
9
9
options = {
10
10
devices = mkOption {
11
11
type = types.listOf types.str;
12
12
+
default = [ ];
12
13
example = [ "/dev/input/by-id/usb-0000_0000-event-kbd" ];
13
13
-
description = mdDoc "Paths to keyboard devices.";
14
14
+
description = mdDoc ''
15
15
+
Paths to keyboard devices.
16
16
+
17
17
+
An empty list, the default value, lets kanata detect which
18
18
+
input devices are keyboards and intercept them all.
19
19
+
'';
14
20
};
15
21
config = mkOption {
16
22
type = types.lines;
···
162
168
};
163
169
164
170
config = mkIf cfg.enable {
171
171
+
warnings =
172
172
+
let
173
173
+
keyboardsWithEmptyDevices = filterAttrs (name: keyboard: keyboard.devices == [ ]) cfg.keyboards;
174
174
+
existEmptyDevices = length (attrNames keyboardsWithEmptyDevices) > 0;
175
175
+
moreThanOneKeyboard = length (attrNames cfg.keyboards) > 1;
176
176
+
in
177
177
+
optional (existEmptyDevices && moreThanOneKeyboard) "One device can only be intercepted by one kanata instance. Setting services.kanata.keyboards.${head (attrNames keyboardsWithEmptyDevices)}.devices = [ ] and using more than one services.kanata.keyboards may cause a race condition.";
178
178
+
165
179
hardware.uinput.enable = true;
166
180
167
181
systemd.services = mapAttrs' mkService cfg.keyboards;