diff options
Diffstat (limited to 'modules/nixos/bootloader.nix')
-rw-r--r-- | modules/nixos/bootloader.nix | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/modules/nixos/bootloader.nix b/modules/nixos/bootloader.nix new file mode 100644 index 0000000..bb807cf --- /dev/null +++ b/modules/nixos/bootloader.nix @@ -0,0 +1,48 @@ +{ lib, config, ... }: let + cfg = config.boot._loader; + usingEfi = cfg.mode == "efi"; + usingBios = cfg.mode == "bios"; +in { + options.boot._loader = { + enable = lib.mkEnableOption "enable unified bootloader config"; + loader = lib.mkOption { + type = lib.types.enum [ "grub" "systemd-boot" ]; + default = "systemd-boot"; + description = "whether to install grub or systemd-boot as the bootloader"; + }; + mode = lib.mkOption { + type = lib.types.enum [ "efi" "bios" ]; + default = "efi"; + description = "whether to install the bootloader in efi or bios mode"; + }; + grub = { + biosDevice = lib.mkOption { + type = lib.types.str; + description = "device to install grub on"; + }; + }; + memtest86.enable = lib.mkEnableOption "make Memtest86+ available from the bootloader"; + }; + + config = lib.mkIf cfg.enable { + boot.loader = { + grub = lib.mkIf (cfg.loader == "grub") { + enable = true; + efiSupport = usingEfi; + efiInstallAsRemovable = usingEfi; + device = if usingBios then cfg.grub.biosDevice else "nodev"; + enableCryptodisk = true; + memtest86.enable = cfg.memtest86.enable; + }; + systemd-boot = lib.mkIf (cfg.loader == "systemd-boot") { + enable = true; + editor = false; + memtest86.enable = cfg.memtest86.enable; + }; + efi = lib.mkIf usingEfi { + efiSysMountPoint = lib.mkIf (cfg.loader == "grub") "/boot/efi"; + canTouchEfiVariables = true; + }; + }; + }; +} |