nixos/build: Add kexec build

This commit is contained in:
Jack O'Sullivan 2022-06-16 19:40:47 +01:00
parent bb9102435f
commit 29ffec5de7

View File

@ -1,10 +1,12 @@
{ lib, extendModules, modulesPath, baseModules, options, config, ... }: { lib, pkgs, extendModules, modulesPath, baseModules, options, config, ... }:
let let
inherit (lib) recursiveUpdate mkOption mkDefault mkIf mkMerge; inherit (lib) recursiveUpdate mkOption mkDefault mkIf mkMerge flatten optional;
inherit (lib.my) mkBoolOpt' dummyOption; inherit (lib.my) mkBoolOpt' dummyOption;
cfg = config.my.build; cfg = config.my.build;
allHardware = (optional config.my.build.allHardware { imports = [ "${modulesPath}/profiles/all-hardware.nix" ]; });
asDevVM = extendModules { asDevVM = extendModules {
modules = [ modules = [
"${modulesPath}/virtualisation/qemu-vm.nix" "${modulesPath}/virtualisation/qemu-vm.nix"
@ -12,9 +14,9 @@ let
]; ];
}; };
asISO = extendModules { asISO = extendModules {
modules = lib.flatten [ modules = flatten [
"${modulesPath}/installer/cd-dvd/iso-image.nix" "${modulesPath}/installer/cd-dvd/iso-image.nix"
(lib.optional config.my.build.allHardware { imports = [ "${modulesPath}/profiles/all-hardware.nix" ]; }) allHardware
{ {
isoImage = { isoImage = {
makeEfiBootable = true; makeEfiBootable = true;
@ -34,6 +36,19 @@ let
} }
]; ];
}; };
asKexecTree = extendModules {
modules = flatten [
"${modulesPath}/installer/netboot/netboot.nix"
allHardware
];
};
mkAsOpt = ext: desc: mkOption {
inherit (ext) type;
default = { };
visible = "shallow";
description = "Configuration as ${desc}.";
};
in in
{ {
options = with lib.types; { options = with lib.types; {
@ -45,24 +60,10 @@ in
"Only applies to some build targets."); "Only applies to some build targets.");
}; };
asDevVM = mkOption { asDevVM = mkAsOpt asDevVM "a development VM";
inherit (asDevVM) type; asISO = mkAsOpt asISO "a bootable .iso image";
default = { }; asContainer = mkAsOpt asContainer "a container";
visible = "shallow"; asKexecTree = mkAsOpt asKexecTree "a kexec-able kernel and initrd";
description = "Configuration as a development VM.";
};
asISO = mkOption {
inherit (asISO) type;
default = { };
visible = "shallow";
description = "Configuration as a bootable .iso image.";
};
asContainer = mkOption {
inherit (asContainer) type;
default = { };
visible = "shallow";
description = "Configuration as a container.";
};
buildAs = options.system.build; buildAs = options.system.build;
}; };
@ -94,6 +95,7 @@ in
devVM = recursiveUpdate config.my.asDevVM.system.build.vm { meta.mainProgram = "run-${config.system.name}-vm"; }; devVM = recursiveUpdate config.my.asDevVM.system.build.vm { meta.mainProgram = "run-${config.system.name}-vm"; };
iso = config.my.asISO.system.build.isoImage; iso = config.my.asISO.system.build.isoImage;
container = config.my.asContainer.system.build.toplevel; container = config.my.asContainer.system.build.toplevel;
kexecTree = config.my.asKexecTree.system.build.kexecTree;
}; };
}; };
}; };