nixos/modprobe: add boot.initrd.extraModprobeConfig option

This option behaves exactly like `boot.extraModprobeConfig`, except that it also includes the generated modprobe.d file in the initrd.
Many years ago, someone tried to include the normal modprobe.d/nixos.conf file generated by `boot.extraModprobeConfig` in the initrd: 0aa2c1dc46. This file contains a reference to a directory with firmware files inside. Including firmware in the initrd made it too big, so the commit was reverted again in 4a4c051a95.
The `boot.extraModprobeConfig` option not changing the initrd caused me much confusion because I tried to set the maximum cache size for ZFS and it didn't work.
Closes https://github.com/NixOS/nixpkgs/issues/25456.
main
Luflosi 3 years ago
parent 68eafd0937
commit 1c58cdbeed
No known key found for this signature in database
GPG Key ID: 4E41E29EDCC345D0
  1. 8
      nixos/doc/manual/from_md/release-notes/rl-2205.section.xml
  2. 2
      nixos/doc/manual/release-notes/rl-2205.section.md
  3. 20
      nixos/modules/system/boot/modprobe.nix
  4. 3
      nixos/modules/system/boot/stage-1.nix

@ -607,6 +607,14 @@
files.
</para>
</listitem>
<listitem>
<para>
A new option
<literal>boot.initrd.extraModprobeConfig</literal> has been
added which can be used to configure kernel modules that are
loaded in the initrd.
</para>
</listitem>
<listitem>
<para>
<literal>fetchFromSourcehut</literal> now allows fetching

@ -211,6 +211,8 @@ In addition to numerous new and upgraded packages, this release has the followin
- The option `services.duplicati.dataDir` has been added to allow changing the location of duplicati's files.
- A new option `boot.initrd.extraModprobeConfig` has been added which can be used to configure kernel modules that are loaded in the initrd.
- `fetchFromSourcehut` now allows fetching repositories recursively
using `fetchgit` or `fetchhg` if the argument `fetchSubmodules`
is set to `true`.

@ -34,6 +34,23 @@ with lib;
type = types.lines;
};
boot.initrd.extraModprobeConfig = mkOption {
default = "";
example =
''
options zfs zfs_arc_max=1073741824
'';
description = ''
Does exactly the same thing as
<option>boot.extraModprobeConfig</option>, except
that the generated <filename>modprobe.conf</filename>
file is also included in the initrd.
This is useful for setting module options for kernel
modules that are loaded during early boot in the initrd.
'';
type = types.lines;
};
};
@ -50,6 +67,9 @@ with lib;
'')}
${config.boot.extraModprobeConfig}
'';
environment.etc."modprobe.d/nixos-initrd.conf".text = ''
${config.boot.initrd.extraModprobeConfig}
'';
environment.etc."modprobe.d/debian.conf".source = pkgs.kmod-debian-aliases;
environment.systemPackages = [ pkgs.kmod ];

@ -338,6 +338,9 @@ let
{ object = pkgs.writeText "mdadm.conf" config.boot.initrd.mdadmConf;
symlink = "/etc/mdadm.conf";
}
{ object = config.environment.etc."modprobe.d/nixos-initrd.conf".source;
symlink = "/etc/modprobe.d/nixos-initrd.conf";
}
{ object = pkgs.runCommand "initrd-kmod-blacklist-ubuntu" {
src = "${pkgs.kmod-blacklist-ubuntu}/modprobe.conf";
preferLocalBuild = true;

Loading…
Cancel
Save