From 2b5fe69994653f383e4e9c1d47e0b928594a158c Mon Sep 17 00:00:00 2001 From: Manuel Thalmann Date: Wed, 1 May 2024 03:07:42 +0200 Subject: [PATCH] Allow enabling spice --- lib/config/custom-build-vm.nix | 35 +++++++++++++++++++++++++++++++--- 1 file changed, 32 insertions(+), 3 deletions(-) diff --git a/lib/config/custom-build-vm.nix b/lib/config/custom-build-vm.nix index 91ad630..5d42460 100644 --- a/lib/config/custom-build-vm.nix +++ b/lib/config/custom-build-vm.nix @@ -31,9 +31,25 @@ in { default = false; }; - qemu.runInBackground = lib.mkOption { - type = lib.types.bool; - default = false; + qemu = { + runInBackground = lib.mkOption { + type = lib.types.bool; + default = false; + }; + + spice = { + enable = lib.mkEnableOption "spice"; + + bindAddress = lib.mkOption { + type = lib.types.str; + default = "127.0.0.1"; + }; + + port = lib.mkOption { + type = lib.types.port; + default = 5900; + }; + }; }; }; }; @@ -54,6 +70,19 @@ in { virtualisation = { runAsRoot = lib.mkIf vmVariant.virtualisation.sharedHostKeys true; + qemu.options = + with { + inherit (vmVariant.virtualisation.qemu) spice; + }; + ( + lib.optional (spice.enable) + ("-spice " + ( + lib.concatStringsSep "," [ + "addr=${lib.escapeShellArg spice.bindAddress}" + "port=${toString spice.port}" + "disable-ticketing=on" + ]))); + sharedDirectories = lib.optionalAttrs (vmVariant.virtualisation.sharedHostKeys) { hostKeys = let