Skip to content

Commit

Permalink
nixos/generic-extlinux-compatible: add mirroredBoots option (NixOS#33…
Browse files Browse the repository at this point in the history
  • Loading branch information
Mic92 authored Sep 18, 2024
2 parents 71df0d5 + 93fb96e commit d66f976
Showing 1 changed file with 41 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,30 @@ in
'';
};

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;
Expand All @@ -72,11 +96,27 @@ in
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.
'';
}
];
};
}

0 comments on commit d66f976

Please sign in to comment.