NixOS udev configuration

I have a new hardware device (Ferris Sweep keyboard). It is pre-flashed with the necessary firmware, but isn’t being recognised by the configuration apps (via or Vial). The error messages are:


* Failed to open the device.

* Device: DPB Ferris sweep
* Vid: 0xC2AB
* Pid: 0x3939


* Received invalid protocol version from device

* Device: DPB Ferris sweep
* Vid: 0xC2AB
* Pid: 0x3939

On a non-NixOS system, I think the following might fix the problem.

export USER_GID=`id -g`; sudo --preserve-env=USER_GID sh -c 'echo "KERNEL==\"hidraw*\", SUBSYSTEM==\"hidraw\", ATTRS{serial}==\"*vial:f64c2b3c*\", MODE=\"0660\", GROUP=\"$USER_GID\", TAG+=\"uaccess\", TAG+=\"udev-acl\"" > /etc/udev/rules.d/99-vial.rules && udevadm control --reload && udevadm trigger'

How do I achieve the same effect in NixOS? I suspect it involves adding services.udev.packages to my configuration.nix, but I don’t know what to write.

It appears that the package definitions for vial and via will create the file /etc/udev/rules.d/92-viia.rules, which take cares of that.

I had been trying to work in a temporary shell using nix-shell -p via[l], which wasn’t working.

So now I added both via and vial to environment.systemPackages and did a nixos-rebuild switch --upgrade. The file did not appear, and the keyboard is still not found by via or Vial.

I rebooted. The file did not appear, and the keyboard is still not found by via or Vial.

What’s stranger still is that I can run Vial, but via is not available – I still have to do nix-shell -p via to be able to run it.

The system is “seeing” the keyboard…

$ dmesg | grep Ferris
[    2.546299] usb 7-4: Product: Ferris sweep
[    2.683786] input: DPB Ferris sweep as /devices/pci0000:40/0000:40:01.1/0000:41:00.0/0000:42:08.0/0000:46:00.3/usb7/7-4/7-4:1.0/0003:C2AB:3939.0001/input/input0
[    2.735115] hid-generic 0003:C2AB:3939.0001: input,hidraw0: USB HID v1.11 Keyboard [DPB Ferris sweep] on usb-0000:46:00.3-4/input0
[    2.735263] hid-generic 0003:C2AB:3939.0002: hiddev96,hidraw1: USB HID v1.11 Device [DPB Ferris sweep] on usb-0000:46:00.3-4/input1
[    2.735384] input: DPB Ferris sweep Mouse as /devices/pci0000:40/0000:40:01.1/0000:41:00.0/0000:42:08.0/0000:46:00.3/usb7/7-4/7-4:1.2/0003:C2AB:3939.0003/input/input1
[    2.735404] input: DPB Ferris sweep System Control as /devices/pci0000:40/0000:40:01.1/0000:41:00.0/0000:42:08.0/0000:46:00.3/usb7/7-4/7-4:1.2/0003:C2AB:3939.0003/input/input2
[    2.787151] input: DPB Ferris sweep Consumer Control as /devices/pci0000:40/0000:40:01.1/0000:41:00.0/0000:42:08.0/0000:46:00.3/usb7/7-4/7-4:1.2/0003:C2AB:3939.0003/input/input3
[    2.787390] hid-generic 0003:C2AB:3939.0003: input,hidraw2: USB HID v1.11 Mouse [DPB Ferris sweep] on usb-0000:46:00.3-4/input2
$ lsusb | grep Ferris
Bus 007 Device 002: ID c2ab:3939 DPB Ferris sweep

Problem was solved by adding the following to my NixOS configuration.

  services.udev.packages = with pkgs; [