blob: f0aacc0305d6feedf0e33a14fce4daf4491cb9eb (
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
|
{
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";
};
useOSProber = lib.mkOption {
type = lib.types.bool;
default = false;
description = "scan for other operating systems";
};
enableEncryption = lib.mkOption {
type = lib.types.bool;
default = false;
description = "Enables LUKS encryption";
};
grubDevice = lib.mkOption {
type = lib.types.str;
default = "nodev";
};
luksDevice = lib.mkOption {
type = lib.types.nullOr lib.types.str;
default = null;
description = "The underlying partition for LUKS";
};
};
config = lib.mkMerge [
{
boot = {
supportedFilesystems = ["ntfs" "btrfs"];
kernelParams = ["quiet" "splash"];
initrd.luks.devices = lib.mkIf (cfg.enableEncryption && cfg.luksDevice != null) {
"crypted" = {
device = cfg.luksDevice;
preLVM = true;
allowDiscards = true;
};
};
};
systemd.settings.Manager.DefaultTimeoutStopSec = "5s";
}
(lib.mkIf (cfg.type == "systemd-boot") {
boot = {
consoleLogLevel = 0;
loader = {
efi.canTouchEfiVariables = true;
timeout = 0;
systemd-boot = {
enable = true;
editor = false;
};
};
};
})
(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;
default =
if cfg.useOSProber
then 2
else 0;
efiSupport = lib.mkDefault (cfg.grubDevice == "nodev");
copyKernels = lib.mkIf cfg.enableEncryption true;
};
};
})
];
}
|