2025-04-06 21:43:36 +02:00
|
|
|
{
|
2025-04-07 14:01:35 +02:00
|
|
|
config,
|
2025-04-06 21:43:36 +02:00
|
|
|
lib,
|
|
|
|
pkgs,
|
|
|
|
...
|
|
|
|
}: let
|
2025-05-15 11:22:57 +02:00
|
|
|
inherit (lib.modules) mkForce mkDefault;
|
2025-04-09 15:31:18 +02:00
|
|
|
inherit (lib.options) mkOption mkEnableOption;
|
|
|
|
inherit (lib.types) int;
|
2025-04-09 15:31:18 +02:00
|
|
|
|
2025-04-07 14:01:35 +02:00
|
|
|
cfg = config.modules.system.boot;
|
2025-04-06 21:43:36 +02:00
|
|
|
in {
|
2025-04-07 14:01:35 +02:00
|
|
|
options.modules.system.boot = {
|
|
|
|
grub.enable = mkEnableOption "Grub, a bloated boot loader";
|
|
|
|
systemd-boot.enable = mkEnableOption "Poetteringboot";
|
2025-04-09 15:31:18 +02:00
|
|
|
timeout = mkOption {
|
|
|
|
description = ''
|
|
|
|
Set the boot loader's timeout. This is 0 by default, but preferably longer on remote servers to make switching to previous generations easier.
|
|
|
|
'';
|
|
|
|
type = int;
|
2025-04-09 15:31:18 +02:00
|
|
|
# I love spamming space
|
2025-04-09 15:31:18 +02:00
|
|
|
default = 0;
|
|
|
|
};
|
2025-04-07 14:01:35 +02:00
|
|
|
};
|
|
|
|
config = {
|
|
|
|
assertions = [
|
|
|
|
{
|
|
|
|
assertion = cfg.systemd-boot.enable || cfg.grub.enable;
|
|
|
|
message = "No bootloader is enabled.";
|
|
|
|
}
|
|
|
|
{
|
|
|
|
assertion = cfg.systemd-boot.enable -> !cfg.grub.enable && cfg.grub.enable -> !cfg.systemd-boot.enable;
|
|
|
|
message = "Please enable only ONE of systemd-boot or grub.";
|
|
|
|
}
|
|
|
|
];
|
|
|
|
boot = {
|
2025-04-09 15:31:18 +02:00
|
|
|
tmp.useTmpfs = true;
|
2025-04-09 15:31:18 +02:00
|
|
|
consoleLogLevel = 0;
|
|
|
|
|
|
|
|
kernelParams = [
|
|
|
|
"quiet"
|
|
|
|
"splash"
|
|
|
|
"rd.systemd.show_status=false"
|
|
|
|
"rd.udev.log_level=3"
|
|
|
|
"udev.log_priority=3"
|
|
|
|
"boot.shell_on_fail"
|
|
|
|
];
|
|
|
|
|
2025-04-07 14:01:35 +02:00
|
|
|
initrd = {
|
2025-04-09 15:31:18 +02:00
|
|
|
verbose = false;
|
2025-04-07 14:01:35 +02:00
|
|
|
systemd.enable = true;
|
2025-04-06 21:22:56 +02:00
|
|
|
};
|
2025-04-07 14:01:35 +02:00
|
|
|
loader = {
|
|
|
|
efi.canTouchEfiVariables = true;
|
2025-05-15 11:22:57 +02:00
|
|
|
timeout = mkDefault cfg.timeout;
|
2025-04-07 14:01:35 +02:00
|
|
|
systemd-boot = {
|
|
|
|
enable = cfg.systemd-boot.enable;
|
2025-04-09 15:31:18 +02:00
|
|
|
# INFO: Leaving this enabled is a security vulneratibility,
|
|
|
|
# since we can just start /bin/sh from there and get root access.
|
|
|
|
# Since I have FDE, this isn't _as_ critical, but it would still be
|
|
|
|
# a bad idea to leave it enabled
|
2025-04-07 14:01:35 +02:00
|
|
|
editor = mkForce false;
|
2025-04-09 15:31:18 +02:00
|
|
|
consoleMode = "auto";
|
2025-04-07 14:01:35 +02:00
|
|
|
configurationLimit = 5;
|
|
|
|
};
|
|
|
|
grub = {
|
|
|
|
enable = cfg.grub.enable;
|
|
|
|
efiSupport = true;
|
|
|
|
device = "nodev";
|
|
|
|
configurationLimit = 5;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
plymouth = {
|
2025-04-09 15:31:18 +02:00
|
|
|
enable = true;
|
|
|
|
themePackages = [
|
|
|
|
(pkgs.adi1090x-plymouth-themes.override
|
|
|
|
{
|
|
|
|
selected_themes = [
|
|
|
|
"hud_3"
|
|
|
|
];
|
|
|
|
})
|
|
|
|
];
|
|
|
|
theme = "hud_3";
|
2025-04-06 21:22:56 +02:00
|
|
|
};
|
|
|
|
};
|
2025-04-09 15:31:18 +02:00
|
|
|
powerManagement = {
|
|
|
|
powerDownCommands = ''
|
|
|
|
${pkgs.plymouth} --show-splash
|
|
|
|
'';
|
|
|
|
resumeCommands = ''
|
|
|
|
${pkgs.plymouth} --quit
|
|
|
|
'';
|
|
|
|
};
|
2024-08-16 13:32:13 +02:00
|
|
|
};
|
|
|
|
}
|