blob: e8dfc111c86635bbf41544a4a6edda71cf347cdc (
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
|
{
config,
lib,
...
}:
let
cfg = config.os.core.bootloader;
in
{
options.os.core.bootloader = {
type = lib.mkOption {
type = lib.types.enum [
"systemd-boot"
"grub"
"none"
];
default = "systemd-boot";
description = "Which bootloader to use";
};
efi = lib.mkOption {
type = lib.types.bool;
default = if cfg.grub.device == "nodev" then true else false;
description = "Whether the system uses UEFI or Legacy BIOS";
};
timeout = lib.mkOption {
type = lib.types.int;
default = 3;
description = "Boot menu timeout in seconds";
};
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";
};
};
#TODO add boot.initrd.luks.reusePassphrases = true; somewhere
luks.enable = lib.mkEnableOption "LUKS encryption support";
};
config = lib.mkMerge [
# 1. Common Kernel & Initrd Settings
{
boot = {
loader = {
timeout = cfg.timeout;
efi.canTouchEfiVariables = lib.mkDefault cfg.efi;
};
supportedFilesystems = [
"ntfs"
"btrfs"
];
kernelParams = [
"quiet"
"splash"
];
consoleLogLevel = 0;
initrd.availableKernelModules = [
"aesni_intel"
"cryptd"
];
};
systemd.settings.Manager.DefaultTimeoutStopSec = "5s";
}
# 2. Systemd-boot Implementation
(lib.mkIf (cfg.type == "systemd-boot") {
boot.loader.systemd-boot = {
enable = true;
editor = false;
consoleMode = "max";
};
})
# 3. GRUB Implementation
(lib.mkIf (cfg.type == "grub") {
boot.loader.grub = {
enable = true;
efiSupport = cfg.efi;
useOSProber = cfg.grub.useOSProber;
default = cfg.grub.defaultEntry;
enableCryptodisk = cfg.luks.enable;
};
})
];
}
|