mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-07-14 06:00:33 +03:00
Merge pull request #80114 from rnhmjoj/initrd
nixos/boot: add option to disable initrd
This commit is contained in:
commit
fab05f17d1
2 changed files with 128 additions and 112 deletions
|
@ -192,22 +192,8 @@ in
|
||||||
|
|
||||||
###### implementation
|
###### implementation
|
||||||
|
|
||||||
config = mkIf (!config.boot.isContainer) {
|
config = mkMerge
|
||||||
|
[ (mkIf config.boot.initrd.enable {
|
||||||
system.build = { inherit kernel; };
|
|
||||||
|
|
||||||
system.modulesTree = [ kernel ] ++ config.boot.extraModulePackages;
|
|
||||||
|
|
||||||
# Implement consoleLogLevel both in early boot and using sysctl
|
|
||||||
# (so you don't need to reboot to have changes take effect).
|
|
||||||
boot.kernelParams =
|
|
||||||
[ "loglevel=${toString config.boot.consoleLogLevel}" ] ++
|
|
||||||
optionals config.boot.vesa [ "vga=0x317" "nomodeset" ];
|
|
||||||
|
|
||||||
boot.kernel.sysctl."kernel.printk" = mkDefault config.boot.consoleLogLevel;
|
|
||||||
|
|
||||||
boot.kernelModules = [ "loop" "atkbd" ];
|
|
||||||
|
|
||||||
boot.initrd.availableKernelModules =
|
boot.initrd.availableKernelModules =
|
||||||
[ # Note: most of these (especially the SATA/PATA modules)
|
[ # 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
|
||||||
|
@ -255,6 +241,22 @@ in
|
||||||
[ # For LVM.
|
[ # For LVM.
|
||||||
"dm_mod"
|
"dm_mod"
|
||||||
];
|
];
|
||||||
|
})
|
||||||
|
|
||||||
|
(mkIf (!config.boot.isContainer) {
|
||||||
|
system.build = { inherit kernel; };
|
||||||
|
|
||||||
|
system.modulesTree = [ kernel ] ++ config.boot.extraModulePackages;
|
||||||
|
|
||||||
|
# Implement consoleLogLevel both in early boot and using sysctl
|
||||||
|
# (so you don't need to reboot to have changes take effect).
|
||||||
|
boot.kernelParams =
|
||||||
|
[ "loglevel=${toString config.boot.consoleLogLevel}" ] ++
|
||||||
|
optionals config.boot.vesa [ "vga=0x317" "nomodeset" ];
|
||||||
|
|
||||||
|
boot.kernel.sysctl."kernel.printk" = mkDefault config.boot.consoleLogLevel;
|
||||||
|
|
||||||
|
boot.kernelModules = [ "loop" "atkbd" ];
|
||||||
|
|
||||||
# The Linux kernel >= 2.6.27 provides firmware.
|
# The Linux kernel >= 2.6.27 provides firmware.
|
||||||
hardware.firmware = [ kernel ];
|
hardware.firmware = [ kernel ];
|
||||||
|
@ -313,7 +315,8 @@ in
|
||||||
};
|
};
|
||||||
|
|
||||||
# The config options that all modules can depend upon
|
# The config options that all modules can depend upon
|
||||||
system.requiredKernelConfig = with config.lib.kernelConfig; [
|
system.requiredKernelConfig = with config.lib.kernelConfig;
|
||||||
|
[
|
||||||
# !!! Should this really be needed?
|
# !!! Should this really be needed?
|
||||||
(isYes "MODULES")
|
(isYes "MODULES")
|
||||||
(isYes "BINFMT_ELF")
|
(isYes "BINFMT_ELF")
|
||||||
|
@ -325,6 +328,8 @@ in
|
||||||
{ assertion = attrs.assertion cfg; inherit (attrs) message; }
|
{ assertion = attrs.assertion cfg; inherit (attrs) message; }
|
||||||
) config.system.requiredKernelConfig;
|
) config.system.requiredKernelConfig;
|
||||||
|
|
||||||
};
|
})
|
||||||
|
|
||||||
|
];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -390,6 +390,17 @@ in
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
boot.initrd.enable = mkOption {
|
||||||
|
type = types.bool;
|
||||||
|
default = !config.boot.isContainer;
|
||||||
|
defaultText = "!config.boot.isContainer";
|
||||||
|
description = ''
|
||||||
|
Whether to enable the NixOS initial RAM disk (initrd). This may be
|
||||||
|
needed to perform some initialisation tasks (like mounting
|
||||||
|
network/encrypted file systems) before continuing the boot process.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
boot.initrd.prepend = mkOption {
|
boot.initrd.prepend = mkOption {
|
||||||
default = [ ];
|
default = [ ];
|
||||||
type = types.listOf types.str;
|
type = types.listOf types.str;
|
||||||
|
@ -555,7 +566,7 @@ in
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
config = mkIf (!config.boot.isContainer) {
|
config = mkIf config.boot.initrd.enable {
|
||||||
assertions = [
|
assertions = [
|
||||||
{ assertion = any (fs: fs.mountPoint == "/") fileSystems;
|
{ assertion = any (fs: fs.mountPoint == "/") fileSystems;
|
||||||
message = "The ‘fileSystems’ option does not specify your root file system.";
|
message = "The ‘fileSystems’ option does not specify your root file system.";
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue