Skip to content

Commit

Permalink
nixos/kmonad: create determinate symlinks
Browse files Browse the repository at this point in the history
(cherry picked from commit 9695e75)

The 25.05 release note is manually removed.
  • Loading branch information
jian-lin committed Jan 2, 2025
1 parent 8bc9074 commit 27d3b1b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
11 changes: 11 additions & 0 deletions nixos/modules/services/hardware/kmonad.nix
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,17 @@ in
config = lib.mkIf cfg.enable {
hardware.uinput.enable = true;

services.udev.extraRules =
let
mkRule = name: ''
ACTION=="add", KERNEL=="event*", SUBSYSTEM=="input", ATTRS{name}=="${name}", ATTRS{id/product}=="5679", ATTRS{id/vendor}=="1235", SYMLINK+="input/by-id/${name}"
'';
in
lib.foldlAttrs (
rules: _: keyboard:
rules + "\n" + mkRule (mkName keyboard.name)
) "" cfg.keyboards;

systemd = {
paths = lib.mapAttrs' (_: mkPath) cfg.keyboards;
services = lib.mapAttrs' (_: mkService) cfg.keyboards;
Expand Down
2 changes: 2 additions & 0 deletions nixos/tests/kmonad.nix
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,7 @@
with subtest("kmonad is running"):
machine.succeed(f"systemctl status {service_name}")
with subtest("kmonad symlink is created"):
machine.wait_for_file(f"/dev/input/by-id/{service_name}", timeout=5)
'';
}

0 comments on commit 27d3b1b

Please sign in to comment.