1 { config, lib, pkgs, ... }:
3 cfg = config.hardware.i2c;
7 options.hardware.i2c = {
8 enable = lib.mkEnableOption ''
9 i2c devices support. By default access is granted to users in the "i2c"
10 group (will be created if non-existent) and any user with a seat, meaning
11 logged on the computer locally
14 group = lib.mkOption {
18 Grant access to i2c devices (/dev/i2c-*) to users in this group.
23 config = lib.mkIf cfg.enable {
25 boot.kernelModules = [ "i2c-dev" ];
27 users.groups = lib.mkIf (cfg.group == "i2c") {
31 services.udev.packages = lib.singleton (pkgs.writeTextFile
32 { name = "i2c-udev-rules";
34 # allow group ${cfg.group} and users with a seat use of i2c devices
35 ACTION=="add", KERNEL=="i2c-[0-9]*", TAG+="uaccess", GROUP="${cfg.group}", MODE="660"
37 destination = "/etc/udev/rules.d/70-i2c.rules";
42 meta.maintainers = [ lib.maintainers.rnhmjoj ];