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