diff --git a/nixos/doc/manual/from_md/release-notes/rl-2111.section.xml b/nixos/doc/manual/from_md/release-notes/rl-2111.section.xml
index 896a797cefbd..abd10a6f9a73 100644
--- a/nixos/doc/manual/from_md/release-notes/rl-2111.section.xml
+++ b/nixos/doc/manual/from_md/release-notes/rl-2111.section.xml
@@ -48,6 +48,14 @@
networking.ucarp.
+
+
+ Users of flashrom should migrate to
+ programs.flashrom.enable
+ and add themselves to the flashrom group to
+ be able to access programmers supported by flashrom.
+
+
diff --git a/nixos/doc/manual/release-notes/rl-2111.section.md b/nixos/doc/manual/release-notes/rl-2111.section.md
index afb129960411..1b7250a18156 100644
--- a/nixos/doc/manual/release-notes/rl-2111.section.md
+++ b/nixos/doc/manual/release-notes/rl-2111.section.md
@@ -16,6 +16,8 @@ In addition to numerous new and upgraded packages, this release has the followin
- [ucarp](https://download.pureftpd.org/pub/ucarp/README), an userspace implementation of the Common Address Redundancy Protocol (CARP). Available as [networking.ucarp](options.html#opt-networking.ucarp.enable).
+- Users of flashrom should migrate to [programs.flashrom.enable](options.html#opt-programs.flashrom.enable) and add themselves to the `flashrom` group to be able to access programmers supported by flashrom.
+
## Backward Incompatibilities {#sec-release-21.11-incompatibilities}
- The `staticjinja` package has been upgraded from 1.0.4 to 2.0.0
diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix
index d3a3143c17f6..2d0f5d37f9e8 100644
--- a/nixos/modules/module-list.nix
+++ b/nixos/modules/module-list.nix
@@ -138,6 +138,7 @@
./programs/file-roller.nix
./programs/firejail.nix
./programs/fish.nix
+ ./programs/flashrom.nix
./programs/flexoptix-app.nix
./programs/freetds.nix
./programs/fuse.nix
diff --git a/nixos/modules/programs/flashrom.nix b/nixos/modules/programs/flashrom.nix
new file mode 100644
index 000000000000..f026c2e31cda
--- /dev/null
+++ b/nixos/modules/programs/flashrom.nix
@@ -0,0 +1,26 @@
+{ config, lib, pkgs, ... }:
+
+with lib;
+
+let
+ cfg = config.programs.flashrom;
+in
+{
+ options.programs.flashrom = {
+ enable = mkOption {
+ type = types.bool;
+ default = false;
+ description = ''
+ Installs flashrom and configures udev rules for programmers
+ used by flashrom. Grants access to users in the "flashrom"
+ group.
+ '';
+ };
+ };
+
+ config = mkIf cfg.enable {
+ services.udev.packages = [ pkgs.flashrom ];
+ environment.systemPackages = [ pkgs.flashrom ];
+ users.groups.flashrom = { };
+ };
+}
diff --git a/pkgs/tools/misc/flashrom/default.nix b/pkgs/tools/misc/flashrom/default.nix
index 66a8b213403c..07a2d02b0b2a 100644
--- a/pkgs/tools/misc/flashrom/default.nix
+++ b/pkgs/tools/misc/flashrom/default.nix
@@ -19,11 +19,17 @@ stdenv.mkDerivation rec {
sha256 = "0ax4kqnh7kd3z120ypgp73qy1knz47l6qxsqzrfkd97mh5cdky71";
};
+ postPatch = ''
+ substituteInPlace util/z60_flashrom.rules \
+ --replace "plugdev" "flashrom"
+ '';
+
# Meson build doesn't build and install manpage. Only Makefile can.
# Build manpage from source directory. Here we're inside the ./build subdirectory
postInstall = ''
make flashrom.8 -C ..
installManPage ../flashrom.8
+ install -Dm644 ../util/z60_flashrom.rules $out/etc/udev/rules.d/flashrom.rules
'';
mesonFlags = lib.optionals stdenv.isAarch64 [ "-Dpciutils=false" ];