system/boot: add includeDefaultModules option

This commit is contained in:
Matej Urbas 2021-01-31 10:58:50 +00:00
parent 4c9a74aa45
commit 2c769d7a6a

View File

@ -156,6 +156,16 @@ in
description = "List of modules that are always loaded by the initrd."; description = "List of modules that are always loaded by the initrd.";
}; };
boot.initrd.includeDefaultModules = mkOption {
type = types.bool;
default = true;
description = ''
This option, if set, adds a collection of default kernel modules
to <option>boot.initrd.availableKernelModules</option> and
<option>boot.initrd.kernelModules</option>.
'';
};
system.modulesTree = mkOption { system.modulesTree = mkOption {
type = types.listOf types.path; type = types.listOf types.path;
internal = true; internal = true;
@ -195,7 +205,8 @@ in
config = mkMerge config = mkMerge
[ (mkIf config.boot.initrd.enable { [ (mkIf config.boot.initrd.enable {
boot.initrd.availableKernelModules = boot.initrd.availableKernelModules =
[ # Note: most of these (especially the SATA/PATA modules) optionals config.boot.initrd.includeDefaultModules ([
# Note: most of these (especially the SATA/PATA modules)
# shouldn't be included by default since nixos-generate-config # shouldn't be included by default since nixos-generate-config
# detects them, but I'm keeping them for now for backwards # detects them, but I'm keeping them for now for backwards
# compatibility. # compatibility.
@ -235,10 +246,11 @@ in
# x86 RTC needed by the stage 2 init script. # x86 RTC needed by the stage 2 init script.
"rtc_cmos" "rtc_cmos"
]; ]);
boot.initrd.kernelModules = boot.initrd.kernelModules =
[ # For LVM. optionals config.boot.initrd.includeDefaultModules [
# For LVM.
"dm_mod" "dm_mod"
]; ];
}) })