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.
This commit is contained in:
Bloxx12 2025-04-09 15:31:18 +02:00
commit 60627d3594

View file

@ -5,13 +5,21 @@
... ...
}: let }: let
inherit (lib.modules) mkForce; inherit (lib.modules) mkForce;
inherit (lib.options) mkEnableOption; inherit (lib.options) mkOption mkEnableOption;
inherit (lib.types) int;
cfg = config.modules.system.boot; cfg = config.modules.system.boot;
in { in {
options.modules.system.boot = { options.modules.system.boot = {
grub.enable = mkEnableOption "Grub, a bloated boot loader"; grub.enable = mkEnableOption "Grub, a bloated boot loader";
systemd-boot.enable = mkEnableOption "Poetteringboot"; 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 = { config = {
assertions = [ assertions = [
@ -33,7 +41,7 @@ in {
loader = { loader = {
efi.canTouchEfiVariables = true; efi.canTouchEfiVariables = true;
# I love spamming space # I love spamming space
timeout = 0; timeout = cfg.timeout;
systemd-boot = { systemd-boot = {
enable = cfg.systemd-boot.enable; enable = cfg.systemd-boot.enable;
editor = mkForce false; editor = mkForce false;