Allow substituting any vm command
This commit is contained in:
parent
c428a2486d
commit
20f1bdaa13
1 changed files with 36 additions and 25 deletions
|
@ -1,35 +1,46 @@
|
||||||
{ config, lib, pkgs, ... }: {
|
{ config, lib, pkgs, ... }:
|
||||||
config = {
|
let
|
||||||
# Replace native `qemu` with `remote-viewer`
|
createVmRunner =
|
||||||
system.build = {
|
vmVariant:
|
||||||
vmWithBootLoader = pkgs.writeShellApplication {
|
pkgs.writeShellApplication {
|
||||||
name = "run-${config.system.name}-vm";
|
name = "run-${config.system.name}-vm";
|
||||||
text = ''
|
text = ''
|
||||||
${config.virtualisation.vmVariant.system.build.vm}/bin/run-${config.system.name}-vm
|
${vmVariant.system.build.vm}/bin/run-${config.system.name}-vm
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
};
|
in
|
||||||
|
{
|
||||||
|
config = {
|
||||||
|
# Replace native `qemu` with `remote-viewer`
|
||||||
|
system.build =
|
||||||
|
with {
|
||||||
|
inherit (config.virtualisation)
|
||||||
|
vmVariantWithBootLoader
|
||||||
|
;
|
||||||
|
};
|
||||||
|
{
|
||||||
|
vmWithBootLoader = createVmRunner vmVariantWithBootLoader;
|
||||||
|
};
|
||||||
|
|
||||||
virtualisation =
|
virtualisation =
|
||||||
let vmConfig = {
|
let vmConfig = {
|
||||||
boot.loader.efi.efiSysMountPoint = lib.mkForce "/boot";
|
boot.loader.efi.efiSysMountPoint = lib.mkForce "/boot";
|
||||||
|
|
||||||
virtualisation = {
|
virtualisation = {
|
||||||
qemu.options = [
|
qemu.options = [
|
||||||
"-display sdl"
|
"-display sdl"
|
||||||
];
|
];
|
||||||
|
|
||||||
sharedDirectories = {
|
sharedDirectories = {
|
||||||
hostKeys = {
|
hostKeys = {
|
||||||
source = "/etc/ssh";
|
source = "/etc/ssh";
|
||||||
target = "/etc/ssh";
|
target = "/etc/ssh";
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
in {
|
||||||
in {
|
vmVariantWithBootLoader = vmConfig;
|
||||||
vmVariant = vmConfig;
|
};
|
||||||
vmVariantWithBootLoader = vmConfig;
|
};
|
||||||
};
|
}
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in a new issue