[Boot] Add a configurationLimit option to limit the maximum number of boot configuration

This commit is contained in:
Antoine Viallon 2022-02-08 12:05:04 +01:00
parent 44ba32bab0
commit 698884fc58
Signed by: aviallon
GPG key ID: 186FC35EDEB25716

View file

@ -23,6 +23,7 @@ let
}; };
}; };
cfg = config.aviallon.boot; cfg = config.aviallon.boot;
generalCfg = config.aviallon.general;
allowUnfree = (types.isType types.attrs config.nixpkgs.config) allowUnfree = (types.isType types.attrs config.nixpkgs.config)
&& (hasAttr "allowUnfree" config.nixpkgs.config) && (hasAttr "allowUnfree" config.nixpkgs.config)
&& (getAttr "allowUnfree" config.nixpkgs.config); && (getAttr "allowUnfree" config.nixpkgs.config);
@ -51,6 +52,12 @@ in
example = !default; example = !default;
type = types.bool; type = types.bool;
}; };
configurationLimit = mkOption {
description = "Maximum number of generations in the boot menu";
default = 30;
example = null;
type = types.int;
};
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
@ -74,10 +81,18 @@ in
loader.grub = { loader.grub = {
version = 2; version = 2;
device = (if cfg.efi then "nodev" else null); device = (if cfg.efi then "nodev" else null);
efiSupport = true; efiSupport = cfg.efi;
configurationLimit = cfg.configurationLimit;
}; };
loader.systemd-boot.enable = cfg.efi && (!cfg.useGrub); loader.systemd-boot = {
enable = cfg.efi && (!cfg.useGrub);
configurationLimit = cfg.configurationLimit;
};
loader.generic-extlinux-compatible = {
configurationLimit = cfg.configurationLimit;
};
loader = { loader = {
efi.efiSysMountPoint = mkDefault "/boot/efi"; efi.efiSysMountPoint = mkDefault "/boot/efi";