nichts/modules/system/boot/module.nix
Bloxx12 60627d3594 boot/module.nix: add timeout option
On desktop systems, it is convenient to have the timeout
at zero, and just spam space when trying to start
a previous generation. On servers however, it is preferable
to have some time to choose the generation, which is
quite convenient if you have to acess is remotely via a
web interface, which tend to be quite slow and unresponsive.
2025-04-18 14:44:08 +02:00

65 lines
1.7 KiB
Nix

{
config,
lib,
pkgs,
...
}: let
inherit (lib.modules) mkForce;
inherit (lib.options) mkOption mkEnableOption;
inherit (lib.types) int;
cfg = config.modules.system.boot;
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;
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 = {
tmp.useTmpfs = true;
initrd = {
verbose = true;
systemd.enable = true;
};
loader = {
efi.canTouchEfiVariables = true;
# I love spamming space
timeout = cfg.timeout;
systemd-boot = {
enable = cfg.systemd-boot.enable;
editor = mkForce false;
configurationLimit = 5;
};
grub = {
enable = cfg.grub.enable;
efiSupport = true;
device = "nodev";
configurationLimit = 5;
};
};
plymouth = {
enable = false;
# font = "${pkgs.jetbrains-mono}/share/fonts/truetype/JetBrainsMono-Regular.ttf";
themePackages = [pkgs.plymouth-matrix-theme];
theme = "matrix";
};
};
};
}