Skip to content

A small utility library to create udev rules with Nix!

License

Notifications You must be signed in to change notification settings

gaelreyrol/udev-nix

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

udev-nix

CI

A small utility library to create udev rules with Nix!

For now this is a pet project to improve my Nix knowledge, the API might change in the future.

Don't hesitate to submit changes that will help me to improve the code 🤗.

DO NOT USE IN PRODUCTION

ToDo

  • Make test derivations to compare output files
  • Assertions on rule keys according to the implementation
  • Improve API through composition
    • Explain API functions
  • Find a way to test rules on devices (in a VM)
  • Create and expose a NixOS Module
  • Inspire from Disko & notnft
  • Publish library on Links category of NixOS Discourse

Usage

Flakes

Import the flake:

{
  inputs = {
    udev-nix.url = "github:gaelreyrol/udev-nix";
  };
}

Create an udev file:

{
  outputs = inputs@{ nixpkgs, udev-nix, ... }:
  let
    udevLib = udev-nix.lib."x86_64-linux";
  in
  {
    packages.x86_64-linux.myUdevFile = udevLib.mkUdevFile "20-test.rules" {
      rules = with udevLib; {
        "Description on my udev file" = {
          Subsystems = operators.match "usb";
          Tag = operators.add "uaccess";
        };
      };
    };
  };
}

It will produce this result:

$ cat /nix/store/pn8abdgzvafkywdpwzcn09hi0vw8np27-20-test.rules
# Description on my udev file
TAG+="uaccess", SUBSYSTEMS=="usb"

About

A small utility library to create udev rules with Nix!

Topics

Resources

License

Stars

Watchers

Forks

Languages