summaryrefslogtreecommitdiff
path: root/os/core/bootloader.nix
diff options
context:
space:
mode:
Diffstat (limited to 'os/core/bootloader.nix')
-rw-r--r--os/core/bootloader.nix106
1 files changed, 53 insertions, 53 deletions
diff --git a/os/core/bootloader.nix b/os/core/bootloader.nix
index 52761f1..7f3a85e 100644
--- a/os/core/bootloader.nix
+++ b/os/core/bootloader.nix
@@ -15,32 +15,50 @@ in
"none"
];
default = "systemd-boot";
- description = "which bootloader to use";
+ description = "Which bootloader to use";
};
- useOSProber = lib.mkOption {
- type = lib.types.bool;
- default = false;
- description = "scan for other operating systems";
- };
- enableEncryption = lib.mkOption {
+
+ efi = lib.mkOption {
type = lib.types.bool;
- default = false;
- description = "Enables LUKS encryption";
+ default = true;
+ description = "Whether the system uses UEFI or Legacy BIOS";
};
- grubDevice = lib.mkOption {
- type = lib.types.str;
- default = "nodev";
+
+ timeout = lib.mkOption {
+ type = lib.types.int;
+ default = 3;
+ description = "Boot menu timeout in seconds";
};
- luksDevice = lib.mkOption {
- type = lib.types.nullOr lib.types.str;
- default = null;
- description = "The underlying partition for LUKS";
+
+ grub = {
+ device = lib.mkOption {
+ type = lib.types.str;
+ default = "nodev";
+ description = "Device to install GRUB to (e.g. /dev/nvme0n1). Use 'nodev' for UEFI.";
+ };
+ useOSProber = lib.mkOption {
+ type = lib.types.bool;
+ default = false;
+ description = "Scan for other operating systems";
+ };
+ defaultEntry = lib.mkOption {
+ type = lib.types.int;
+ default = 0;
+ description = "Index of the default boot entry";
+ };
};
+
+ luks.enable = lib.mkEnableOption "LUKS encryption support";
};
config = lib.mkMerge [
+ # 1. Common Kernel & Initrd Settings
{
boot = {
+ loader = {
+ timeout = cfg.timeout;
+ efi.canTouchEfiVariables = cfg.efi;
+ };
supportedFilesystems = [
"ntfs"
"btrfs"
@@ -49,53 +67,35 @@ in
"quiet"
"splash"
];
- initrd = {
- availableKernelModules = [
- "aesni_intel"
- "cryptd"
- ];
- luks.devices = lib.mkIf (cfg.enableEncryption && cfg.luksDevice != null) {
- "crypted" = {
- device = cfg.luksDevice;
- preLVM = true;
- allowDiscards = true;
- };
- };
- };
+ consoleLogLevel = 0;
+ initrd.availableKernelModules = [
+ "aesni_intel"
+ "cryptd"
+ ];
};
systemd.settings.Manager.DefaultTimeoutStopSec = "5s";
}
+ # 2. Systemd-boot Implementation
(lib.mkIf (cfg.type == "systemd-boot") {
- boot = {
- consoleLogLevel = 0;
- loader = {
- efi.canTouchEfiVariables = true;
- timeout = 0;
- systemd-boot = {
- enable = true;
- editor = false;
- consoleMode = "max";
- };
- };
+ boot.loader.systemd-boot = {
+ enable = true;
+ editor = false;
+ consoleMode = "max";
};
})
+ # 3. GRUB Implementation
(lib.mkIf (cfg.type == "grub") {
- boot.loader = {
- timeout = 3;
- efi.canTouchEfiVariables = cfg.grubDevice == "nodev";
- grub = {
- enable = true;
- device = cfg.grubDevice;
- useOSProber = cfg.useOSProber;
- enableCryptodisk = cfg.enableEncryption;
+ boot.loader.grub = {
+ enable = true;
+ device = cfg.grub.device;
+ efiSupport = cfg.efi;
+ useOSProber = cfg.grub.useOSProber;
+ default = cfg.grub.defaultEntry;
- default = if cfg.useOSProber then 2 else 0;
-
- efiSupport = lib.mkDefault (cfg.grubDevice == "nodev");
- copyKernels = lib.mkIf cfg.enableEncryption true;
- };
+ enableCryptodisk = cfg.luks.enable;
+ copyKernels = true;
};
})
];