UHK keyboard: latest correct way to setup?

Hi I see this old thread that has custom code in the solution, but I think it’s out of date because I see there’s now two packages in the mix package search: uhk-agent and uhk-udev-rules

Am I correct that one should only need to install those two packages in their package listing, and be done? Or is there more? I’m asking because I did this, but after a reboot agent still shows me a permissions-prompt

Thanks!

I believe uhk-udev-rules should be put in services.udev.packages.

1 Like

Thanks a bunch, this helped me figure it out! And now I actually see there’s a NixOS Configuration tab in the search.nixos.org packages listing that might’ve helped me (though it says something different than what worked for me below: it points to environment.systemPackages).

Anyway, here’s a full example solution in case anyone like me[1] is searching the web in the future:

step 1: install the agent in the usual place you install packages (eg: the same place you’d put firefox):

 { config, pkgs, ... }:
 
 {
   # Define a user account. Don't forget to set a password with ‘passwd’.
   users.users.myusername = {
     isNormalUser = true;
     description = "myusername";
     extraGroups = [ ... ];
     packages = with pkgs; [
       firefox # example

+      uhk-agent
     ];
   };
 }

step 2: install the udev rules slightly differently: somewhere you have some services declarations; for me this was in a different file and looks like:

# Edit this configuration file to define what should be installed on
# your system.  Help is available in the configuration.nix(5) man page
# and in the NixOS manual (accessible by running ‘nixos-help’).

 { nixpkgs, config, pkgs, ... }:

 {
   # ...snipped for brevity; only purpose of this snippet is to show
   # a subset of other things one might recognize, alongside
   # which I was able to make uhk udev rules work. 

   # Enable the X11 windowing system.
   services.xserver.enable = true; 

+  services.udev.packages = [
+      pkgs.uhk-udev-rules
+  ];
 }

[1]: “like me”: read: doesn’t fully understand these configs and variables, but uses nixos quite happily

Check out https://search.nixos.org/options?channel=23.05&query=uhk

Neat, I didn’t know those options were available. Looks nicer than adding udev packages.

That’s basically what that option does for you

Thanks both of you. for posterity, here’s an updated version of my previous “solution” snippet above, for future web-searchers.

step 1: install the agent in the usual place you install packages (eg: the same place you’d put firefox):

 { config, pkgs, ... }:
 
 {
   # Define a user account. Don't forget to set a password with ‘passwd’.
   users.users.myusername = {
     isNormalUser = true;
     description = "myusername";
     extraGroups = [ ... ];
     packages = with pkgs; [
       firefox # example

+      uhk-agent
     ];
   };
 }

step 2: install the udev rules slightly differently: somewhere you have some services declarations; for me this was in a different file and looks like:

# Edit this configuration file to define what should be installed on
# your system.  Help is available in the configuration.nix(5) man page
# and in the NixOS manual (accessible by running ‘nixos-help’).

 { nixpkgs, config, pkgs, ... }:

 {
   # ...snipped for brevity; only purpose of this snippet is to show
   # a subset of other things one might recognize, alongside
   # which I was able to make uhk udev rules work. 

   # Enable the X11 windowing system.
   services.xserver.enable = true; 

-  services.udev.packages = [
-      pkgs.uhk-udev-rules
-      # Only have to remove this^ line if you already have it; otherwise ignore this
-  ];
+ hardware.keyboard.uhk.enable = true; # does the same as the 3 older lines above
 }
1 Like