diff --git a/nixos/modules/services/hardware/udev.nix b/nixos/modules/services/hardware/udev.nix
index 63027f7744dc..d48b5444677c 100644
--- a/nixos/modules/services/hardware/udev.nix
+++ b/nixos/modules/services/hardware/udev.nix
@@ -202,12 +202,26 @@ in
'';
};
- extraRules = mkOption {
+ initrdRules = mkOption {
default = "";
example = ''
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:1D:60:B9:6D:4F", KERNEL=="eth*", NAME="my_fast_network_card"
'';
type = types.lines;
+ description = ''
+ udev rules to include in the initrd
+ only. They'll be written into file
+ 99-local.rules. Thus they are read and applied
+ after the essential initrd rules.
+ '';
+ };
+
+ extraRules = mkOption {
+ default = "";
+ example = ''
+ ENV{ID_VENDOR_ID}=="046d", ENV{ID_MODEL_ID}=="0825", ENV{PULSE_IGNORE}="1"
+ '';
+ type = types.lines;
description = ''
Additional udev rules. They'll be written
into file 99-local.rules. Thus they are
@@ -284,6 +298,13 @@ in
boot.kernelParams = mkIf (!config.networking.usePredictableInterfaceNames) [ "net.ifnames=0" ];
+ boot.initrd.extraUdevRulesCommands = optionalString (cfg.initrdRules != "")
+ ''
+ cat <<'EOF' > $out/99-local.rules
+ ${cfg.initrdRules}
+ EOF
+ '';
+
environment.etc =
{
"udev/rules.d".source = udevRules;