From 32a4144c42bde88ee39eb455b5da09b43c88d0d5 Mon Sep 17 00:00:00 2001 From: Mohammad Rafiq Date: Wed, 18 Jun 2025 21:05:48 +0800 Subject: [PATCH] feat(nixos): add configurationLimit option to systemd-boot --- lib/default.nix | 6 ++++ modules/nixos/machine/bootloader/default.nix | 34 ++++++++++---------- 2 files changed, 23 insertions(+), 17 deletions(-) diff --git a/lib/default.nix b/lib/default.nix index 760f52c..087cab9 100644 --- a/lib/default.nix +++ b/lib/default.nix @@ -19,6 +19,12 @@ rec { type = lib.types.attrs; default = { }; }; + mkIntOption = + default: + lib.mkOption { + type = lib.types.int; + inherit default; + }; mkStrOption = lib.mkOption { type = lib.types.str; default = ""; diff --git a/modules/nixos/machine/bootloader/default.nix b/modules/nixos/machine/bootloader/default.nix index 9fc63fb..b5cedea 100644 --- a/modules/nixos/machine/bootloader/default.nix +++ b/modules/nixos/machine/bootloader/default.nix @@ -4,27 +4,27 @@ ... }: let - inherit (lib.pantheon) mkStrOption; + inherit (lib.pantheon) mkIntOption mkStrOption; cfg = config.machine.bootloader; in { options.machine.bootloader = { type = mkStrOption; + configurationLimit = mkIntOption 5; + }; + config.boot = { + initrd.availableKernelModules = [ + "nvme" + "xhci_pci" + "ahci" + "usbhid" + "usb_storage" + "sd_mod" + ]; + loader.efi.canTouchEfiVariables = true; + loader.systemd-boot = { + enable = cfg.type == "systemd-boot"; + inherit (cfg) configurationLimit; + }; }; - config = lib.mkMerge [ - { - boot.initrd.availableKernelModules = [ - "nvme" - "xhci_pci" - "ahci" - "usbhid" - "usb_storage" - "sd_mod" - ]; - boot.loader.efi.canTouchEfiVariables = true; - } - (lib.mkIf (config.machine.bootloader.type == "systemd-boot") { - boot.loader.systemd-boot.enable = true; - }) - ]; }