mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-06-09 19:13:26 +03:00

After final improvements to the official formatter implementation, this commit now performs the first treewide reformat of Nix files using it. This is part of the implementation of RFC 166. Only "inactive" files are reformatted, meaning only files that aren't being touched by any PR with activity in the past 2 months. This is to avoid conflicts for PRs that might soon be merged. Later we can do a full treewide reformat to get the rest, which should not cause as many conflicts. A CI check has already been running for some time to ensure that new and already-formatted files are formatted, so the files being reformatted here should also stay formatted. This commit was automatically created and can be verified using nix-builda08b3a4d19
.tar.gz \ --argstr baseRevb32a094368
result/bin/apply-formatting $NIXPKGS_PATH
51 lines
1.1 KiB
Nix
51 lines
1.1 KiB
Nix
{
|
|
config,
|
|
lib,
|
|
pkgs,
|
|
...
|
|
}:
|
|
let
|
|
cfg = config.hardware.i2c;
|
|
in
|
|
|
|
{
|
|
options.hardware.i2c = {
|
|
enable = lib.mkEnableOption ''
|
|
i2c devices support. By default access is granted to users in the "i2c"
|
|
group (will be created if non-existent) and any user with a seat, meaning
|
|
logged on the computer locally
|
|
'';
|
|
|
|
group = lib.mkOption {
|
|
type = lib.types.str;
|
|
default = "i2c";
|
|
description = ''
|
|
Grant access to i2c devices (/dev/i2c-*) to users in this group.
|
|
'';
|
|
};
|
|
};
|
|
|
|
config = lib.mkIf cfg.enable {
|
|
|
|
boot.kernelModules = [ "i2c-dev" ];
|
|
|
|
users.groups = lib.mkIf (cfg.group == "i2c") {
|
|
i2c = { };
|
|
};
|
|
|
|
services.udev.packages = lib.singleton (
|
|
pkgs.writeTextFile {
|
|
name = "i2c-udev-rules";
|
|
text = ''
|
|
# allow group ${cfg.group} and users with a seat use of i2c devices
|
|
ACTION=="add", KERNEL=="i2c-[0-9]*", TAG+="uaccess", GROUP="${cfg.group}", MODE="660"
|
|
'';
|
|
destination = "/etc/udev/rules.d/70-i2c.rules";
|
|
}
|
|
);
|
|
|
|
};
|
|
|
|
meta.maintainers = [ lib.maintainers.rnhmjoj ];
|
|
|
|
}
|