nichts/modules/system/boot/boot.mod.nix

96 lines
2.5 KiB
Nix
Raw Normal View History

2025-04-06 21:43:36 +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;
inherit (lib.options) mkOption mkEnableOption;
inherit (lib.types) int;
cfg = config.modules.system.boot;
2025-04-06 21:43:36 +02:00
in {
options.modules.system.boot = {
grub.enable = mkEnableOption "Grub, a bloated boot loader";
systemd-boot.enable = mkEnableOption "Poetteringboot";
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
default = 0;
};
};
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"
];
initrd = {
2025-04-09 15:31:18 +02:00
verbose = false;
systemd.enable = true;
2025-04-06 21:22:56 +02:00
};
loader = {
efi.canTouchEfiVariables = true;
2025-05-15 11:22:57 +02:00
timeout = mkDefault cfg.timeout;
systemd-boot = {
2025-07-08 13:57:04 +02:00
inherit (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
editor = mkForce false;
2025-04-09 15:31:18 +02:00
consoleMode = "auto";
configurationLimit = 5;
};
grub = {
2025-07-08 13:57:04 +02:00
inherit (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
'';
};
};
}