uefi/vm: Use composeConfig
This means that the `uefi-x86_64` system is now almost directly usable
into a "non-Mobile" NixOS system.
@@ -4,7 +4,7 @@ let
# This particular VM module is only enabled for the uefi system type.
enabled = config.mobile.system.type == "uefi";
- inherit (lib) mkAfter mkIf mkOption types;
+ inherit (lib) mkAfter mkIf mkMerge mkOption types;
inherit (config.mobile) device hardware;
inherit (config.mobile.boot) stage-1;
inherit (config.mobile.outputs.uefi) disk-image;
@@ -16,6 +16,15 @@ in
{
options = {
mobile = {
+ quirks.uefi.enableVM = mkOption {
+ type = types.bool;
+ default = false;
+ internal = true;
+ description = ''
+ Internal switch to select whether the `outputs.uefi.vm` value points
+ to the composeConfig usage, or to the actual output.
+ '';
+ };
outputs = {
uefi = {
vm = mkOption {
@@ -29,7 +38,9 @@ in
};
};
};
- config = mkIf enabled {
+ config = mkMerge [
+ (mkIf config.mobile.quirks.uefi.enableVM {
+ boot.kernelPackages = pkgs.linuxPackages_5_4;
boot.kernelParams = mkAfter [
"console=ttyS0"
];
@@ -68,5 +79,13 @@ in
${pkgs.qemu}/bin/qemu-system-${pkgs.stdenv.targetPlatform.qemuArch} "''${ARGS[@]}" "''${@}"
'';
};
+ })
+ (mkIf (!config.mobile.quirks.uefi.enableVM) {
+ mobile.outputs.uefi.vm = (config.lib.mobile-nixos.composeConfig {
+ config = {
+ mobile.quirks.uefi.enableVM = true;
};
+ }).config.mobile.outputs.uefi.vm;
+ })
+ ];
}
