summaryrefslogtreecommitdiff
path: root/modules/root/bootloader.nix
blob: 0a45264dbd0d44384aa663205f07e4a70e0ed038 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
{ lib, config, ... }: {
	options = {
		bootloader.loader = lib.mkOption {
			type = lib.types.enum [ "grub" "systemd-boot" ];
			default = "systemd-boot";
			description = "whether to install grub or systemd-boot as the bootloader";
		};
		bootloader.mode = lib.mkOption {
			type = lib.types.enum [ "efi" "bios" ];
			default = "efi";
			description = "whether to install the bootloader in efi or bios mode";
		};
		bootloader.grub = {
			biosDevice = lib.mkOption {
				type = lib.types.str;
				description = "device to install grub on";
			};
		};
		bootloader.memtest86.enable = lib.mkEnableOption "make Memtest86+ available from the bootloader";
	};

	config = {
		boot.loader = {
			grub = {
				enable = config.bootloader.loader == "grub";
				efiSupport = config.bootloader.mode == "efi";
				efiInstallAsRemovable = config.bootloader.mode == "efi";
				device = if config.bootloader.mode == "bios" then config.bootloader.grub.biosDevice else "nodev";
				enableCryptodisk = true;
				memtest86.enable = config.bootloader.memtest86.enable;
			};
			systemd-boot = {
				enable = config.bootloader.loader == "systemd-boot";
				editor = false;
				memtest86.enable = config.bootloader.memtest86.enable;
			};
			efi = lib.mkIf (config.bootloader.mode == "efi") {
				efiSysMountPoint = lib.mkIf (config.bootloader.loader == "grub") "/boot/efi";
				canTouchEfiVariables = true;
			};
		};
	};
}