From 1c58cdbeed880e99d816c234a954d4cdfc073b6c Mon Sep 17 00:00:00 2001 From: Luflosi Date: Sun, 7 Nov 2021 20:49:45 +0100 Subject: 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: 0aa2c1dc46779a3df6c4e02d3fae39b0de297be8. 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 4a4c051a95b6b8da3a13d7955087e915e6dd4bf7. 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. --- nixos/modules/system/boot/modprobe.nix | 20 ++++++++++++++++++++ nixos/modules/system/boot/stage-1.nix | 3 +++ 2 files changed, 23 insertions(+) (limited to 'nixos/modules/system') diff --git a/nixos/modules/system/boot/modprobe.nix b/nixos/modules/system/boot/modprobe.nix index c75f32c4d99..7426d148891 100644 --- a/nixos/modules/system/boot/modprobe.nix +++ b/nixos/modules/system/boot/modprobe.nix @@ -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 + , except + that the generated modprobe.conf + 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 ]; diff --git a/nixos/modules/system/boot/stage-1.nix b/nixos/modules/system/boot/stage-1.nix index 6dfe6b939ab..9c684fbada2 100644 --- a/nixos/modules/system/boot/stage-1.nix +++ b/nixos/modules/system/boot/stage-1.nix @@ -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; -- cgit 1.4.1