8 cfg = config.hardware.i2c;
12 options.hardware.i2c = {
13 enable = lib.mkEnableOption ''
14 i2c devices support. By default access is granted to users in the "i2c"
15 group (will be created if non-existent) and any user with a seat, meaning
16 logged on the computer locally
19 group = lib.mkOption {
23 Grant access to i2c devices (/dev/i2c-*) to users in this group.
28 config = lib.mkIf cfg.enable {
30 boot.kernelModules = [ "i2c-dev" ];
32 users.groups = lib.mkIf (cfg.group == "i2c") {
36 services.udev.packages = lib.singleton (
38 name = "i2c-udev-rules";
40 # allow group ${cfg.group} and users with a seat use of i2c devices
41 ACTION=="add", KERNEL=="i2c-[0-9]*", TAG+="uaccess", GROUP="${cfg.group}", MODE="660"
43 destination = "/etc/udev/rules.d/70-i2c.rules";
49 meta.maintainers = [ lib.maintainers.rnhmjoj ];