NixOSConfig/lib/config/custom-build-vm.nix

47 lines
1 KiB
Nix
Raw Normal View History

2024-04-30 13:00:02 +00:00
{ config, lib, pkgs, ... }:
let
createVmRunner =
vmVariant:
pkgs.writeShellApplication {
name = "run-${config.system.name}-vm";
text = ''
2024-04-30 13:00:02 +00:00
${vmVariant.system.build.vm}/bin/run-${config.system.name}-vm
'';
};
2024-04-30 13:00:02 +00:00
in
{
config = {
# Replace native `qemu` with `remote-viewer`
system.build =
with {
inherit (config.virtualisation)
vmVariantWithBootLoader
;
};
{
vmWithBootLoader = createVmRunner vmVariantWithBootLoader;
};
2024-04-30 13:00:02 +00:00
virtualisation =
let vmConfig = {
boot.loader.efi.efiSysMountPoint = lib.mkForce "/boot";
2024-04-30 13:00:02 +00:00
virtualisation = {
qemu.options = [
"-display sdl"
];
2024-04-30 13:00:02 +00:00
sharedDirectories = {
hostKeys = {
source = "/etc/ssh";
target = "/etc/ssh";
};
};
};
};
2024-04-30 13:00:02 +00:00
in {
vmVariantWithBootLoader = vmConfig;
};
};
}