infra/nix/tests/buildvmwithbootloader/build-vm.nix
2022-11-03 20:46:14 +01:00

35 lines
910 B
Nix

{ system ? builtins.currentSystem, vmPkgsPath, buildPkgsPath, nixosConfigPath }:
let
buildPkgs = import buildPkgsPath { };
vmPkgs' = import vmPkgsPath { };
vmPkgs = vmPkgs' // {
runtimeShell = "${vmPkgs'.bash}/${vmPkgs'.bash.shellPath}";
};
importWithPkgs = { path, pkgs }:
args:
import path (args // { inherit pkgs; });
nixosConfig = importWithPkgs {
path = "${nixosConfigPath}";
pkgs = vmPkgs;
};
vmConfig = importWithPkgs {
path = "${buildPkgsPath}/nixos/modules/virtualisation/qemu-vm.nix";
pkgs = vmPkgs;
};
evalConfig = importWithPkgs {
path = "${vmPkgsPath}/nixos/lib/eval-config.nix";
pkgs = null;
};
vmWithBootLoaderConfigMixed = (evalConfig {
modules = [
nixosConfig
vmConfig
{ virtualisation.useBootLoader = true; }
];
}).config;
in { vmWithBootLoaderMixed = vmWithBootLoaderConfigMixed.system.build.vm; }