nixos/generic-extlinux-compatible: add mirroredBoots option (#335131)

Changed files
+41 -1
nixos
modules
system
boot
loader
generic-extlinux-compatible
+41 -1
nixos/modules/system/boot/loader/generic-extlinux-compatible/default.nix
···
'';
};
+
mirroredBoots = mkOption {
+
default = [ { path = "/boot"; } ];
+
example = [
+
{ path = "/boot1"; }
+
{ path = "/boot2"; }
+
];
+
description = ''
+
Mirror the boot configuration to multiple paths.
+
'';
+
+
type = with types; listOf (submodule {
+
options = {
+
path = mkOption {
+
example = "/boot1";
+
type = types.str;
+
description = ''
+
The path to the boot directory where the extlinux-compatible
+
configuration files will be written.
+
'';
+
};
+
};
+
});
+
};
+
populateCmd = mkOption {
type = types.str;
readOnly = true;
···
builderArgs = "-g ${toString cfg.configurationLimit} -t ${timeoutStr}"
+ lib.optionalString (dtCfg.name != null) " -n ${dtCfg.name}"
+ lib.optionalString (!cfg.useGenerationDeviceTree) " -r";
+
installBootLoader = pkgs.writeScript "install-extlinux-conf.sh" (''
+
#!${pkgs.runtimeShell}
+
set -e
+
'' + flip concatMapStrings cfg.mirroredBoots (args: ''
+
${builder} ${builderArgs} -d '${args.path}' -c "$@"
+
''));
in
mkIf cfg.enable {
-
system.build.installBootLoader = "${builder} ${builderArgs} -c";
+
system.build.installBootLoader = installBootLoader;
system.boot.loader.id = "generic-extlinux-compatible";
boot.loader.generic-extlinux-compatible.populateCmd = "${populateBuilder} ${builderArgs}";
+
+
assertions = [
+
{
+
assertion = cfg.mirroredBoots != [ ];
+
message = ''
+
You must not remove all elements from option 'boot.loader.generic-extlinux-compatible.mirroredBoots',
+
otherwise the system will not be bootable.
+
'';
+
}
+
];
};
}