diff --git a/lib/config/custom-build-vm.nix b/lib/config/custom-build-vm.nix new file mode 100644 index 0000000..6eec80e --- /dev/null +++ b/lib/config/custom-build-vm.nix @@ -0,0 +1,35 @@ +{ config, lib, pkgs, ... }: { + config = { + # Replace native `qemu` with `remote-viewer` + system.build = { + vmWithBootLoader = pkgs.writeShellApplication { + name = "run-${config.system.name}-vm"; + text = '' + ${config.virtualisation.vmVariant.system.build.vm}/bin/run-${config.system.name}-vm + ''; + }; + }; + + virtualisation = + let config = { + boot.loader.efi.efiSysMountPoint = lib.mkForce "/boot"; + + virtualisation = { + qemu.options = [ + "-display sdl" + ]; + + sharedDirectories = { + hostKeys = { + source = "/etc/ssh"; + target = "/etc/ssh"; + }; + }; + }; + }; + in { + vmVariant = config; + vmVariantWithBootLoader = config; + }; + }; +} diff --git a/lib/system.nix b/lib/system.nix index eb3c03b..4ac2b4c 100644 --- a/lib/system.nix +++ b/lib/system.nix @@ -17,29 +17,9 @@ { config, pkgs, lib, ... }: { imports = [ machineConfig + ./config/custom-build-vm.nix ]; - virtualisation = - let - config = { - boot.loader.efi.efiSysMountPoint = lib.mkVMOverride "/boot"; - - virtualisation.qemu.options = [ - "-display sdl" - ]; - - virtualisation.sharedDirectories = { - keys = { - source = "/etc/ssh"; - target = "/etc/ssh"; - }; - }; - }; - in { - vmVariant = config; - vmVariantWithBootLoader = config; - }; - # Networking networking.hostName = name; })