From 1ff6f0eb48961e6482ec1b7d0dd9b606e85ddc79 Mon Sep 17 00:00:00 2001 From: adikro Date: Thu, 12 Feb 2026 00:41:07 +0100 Subject: disko and bootloader changes --- os/core/bootloader.nix | 106 ++++++++++++++++++++++++------------------------- 1 file changed, 53 insertions(+), 53 deletions(-) (limited to 'os/core/bootloader.nix') 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; }; }) ]; -- cgit v1.3