feat(loader): adding support for extlinux

This commit is contained in:
2025-09-07 15:22:35 +02:00
parent 7ac62e9ca2
commit 38dfeffbe8
2 changed files with 17 additions and 7 deletions

View File

@@ -8,6 +8,9 @@
}; };
loader = { loader = {
default = { default = {
enable = false;
};
extlinux = {
enable = true; enable = true;
}; };
lanzaboote = { lanzaboote = {

View File

@@ -23,6 +23,9 @@ in
lanzaboote = { lanzaboote = {
enable = mkEnableOption "Enable Lanzaboote boot loader configuration."; enable = mkEnableOption "Enable Lanzaboote boot loader configuration.";
}; };
extlinux = {
enable = mkEnableOption "Enable extlinux boot loader configuration.";
};
}; };
}; };
@@ -34,14 +37,18 @@ in
{ {
assertions = [ assertions = [
{ {
assertion = !(cfg.default.enable && cfg.lanzaboote.enable); assertion =
message = "Only one of nixos.boot.loader.default.enable and nixos.boot.loader.lanzaboote.enable can be set to true."; (lib.count (x: x) [
cfg.default.enable
cfg.lanzaboote.enable
cfg.extlinux.enable
]) <= 1;
message = "Only one of nixos.boot.loader.{default,lanzaboote,extlinux}.enable can be set to true.";
} }
]; ];
} }
(mkIf cfg.default.enable { (mkIf cfg.default.enable {
# Default boot loader configuration
boot.loader = { boot.loader = {
systemd-boot.enable = true; systemd-boot.enable = true;
systemd-boot.graceful = true; systemd-boot.graceful = true;
@@ -49,18 +56,18 @@ in
}; };
}) })
(mkIf cfg.extlinux.enable {
boot.loader.generic-extlinux-compatible.enable = true;
})
(mkIf cfg.lanzaboote.enable { (mkIf cfg.lanzaboote.enable {
# Lanzaboote boot loader configuration
boot = { boot = {
lanzaboote = { lanzaboote = {
enable = true; enable = true;
pkiBundle = "/var/lib/sbctl"; pkiBundle = "/var/lib/sbctl";
}; };
# We let Lanzaboote install systemd-boot
loader.systemd-boot.enable = mkForce false; loader.systemd-boot.enable = mkForce false;
}; };
environment.systemPackages = [ pkgs.sbctl ]; environment.systemPackages = [ pkgs.sbctl ];
}) })
]; ];