Udev rules for a package

There is an application called Ledger Live that allows connecting and managing hardware wallets.
While troubleshooting, I found that they recommend updating udev rules via a bash script they provide.
Of course, their script won’t work because /etc/udev/rules.d links to nix store. And I know that there are ways to do it via configuration.nix.
But if those rules are necessary for the application to work, it kind of makes it feel natural to bundle it with the package. So every user of the package doesn’t need to troubleshoot. But that probably won’t fit into nixpkgs concept (or maybe it can, I am quite new to nix).
Maybe it should be extended into NixOS module? Or put a notice somewhere for the package user?
What is the recommended approach here?

Found hardware.ledger.enable option in NixOS. But still be nice to have some description in package. Maybe a wiki page with instructions to enable that option is the recommended approach here?

if a package contains udev rules in $out/{etc, lib}/udev You can load them using:

services.udev.packages = [ pkgs.ledger-live ];
1 Like

It doesn’t, it contains them in separate repo. However, there is a separate package that only contains those udev rules which nixos option hardware.ledger.enable utilizes in the way you demonstrated above.
I was just wondering how things work, and how a user meant to find that option. I guess creating a wiki page is the best strategy here. Thanks for help anyway.

1 Like

Hi,
I’ve just searched for the same issue and found this topic.
I also search for Trezor udev rules. I found a similar nix package with the rules, but nothing similar to the option hardware.ledge.enable you mentioned.
So for completeness let me put a working solution here:

  services = {
    udev.packages = with pkgs; [ 
        ledger-udev-rules
        trezor-udev-rules
        # potentially even more if you need them
    ];
  };

Nothing really fancy, but - as I said - I decided to post it here for completeness. Maybe it’ll save some tears to somebody.

2 Likes

Thank you for posting this @bratfizyk! It’s exactly what I needed and worked perfectly to get the udev rules for openrgb-with-all-plugins to load from my configuration.nix. Specifically:

  services = {
      udev.packages = with pkgs; [ 
          openrgb-with-all-plugins
      ];
    };
1 Like