mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-25 00:12:56 +00:00
nixos/generic-extlinux-compatible: add mirroredBoots option (#335131)
This commit is contained in:
commit
d66f976cee
@ -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;
|
||||
@ -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.
|
||||
'';
|
||||
}
|
||||
];
|
||||
};
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user