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; - }) - ]; }