From 4226f6fdfd886bc16fcc75129e91d29fd7ed23be Mon Sep 17 00:00:00 2001 From: Git Sagar Date: Mon, 8 Jun 2026 13:53:00 +0530 Subject: [PATCH] add spice.vgamem option for QXL video memory When spice.vgamem is set (e.g. 64), uses -device qxl-vga,vgamem_mb=N instead of -vga qxl (which defaults to 16MB). When null (default), uses -vga qxl for backwards compatibility. Co-Authored-By: Claude Opus 4.6 (1M context) --- nixos/vms/config.nix | 2 +- nixos/vms/submoduleOptions.nix | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/nixos/vms/config.nix b/nixos/vms/config.nix index 6be8a44..d851fa2 100644 --- a/nixos/vms/config.nix +++ b/nixos/vms/config.nix @@ -178,7 +178,7 @@ let ${optionalString vmCfg.vnc.enable "-vnc ${vncArgs}"} \ ${optionalString (vmCfg.spice.enable && vmCfg.spice.passwordFile != null) "-object secret,id=spice-pass-${vmCfg.name},file=${escapeShellArg vmCfg.spice.passwordFile}"} \ ${optionalString vmCfg.spice.enable "-spice addr=${vmCfg.spice.addr},port=${toString vmCfg.spice.port}${optionalString (vmCfg.spice.passwordFile == null) ",disable-ticketing=on"}${optionalString (vmCfg.spice.passwordFile != null) ",password-secret=spice-pass-${vmCfg.name}"}"} \ - ${optionalString vmCfg.spice.enable "-vga ${vmCfg.spice.displayDevice}"} \ + ${optionalString vmCfg.spice.enable (if vmCfg.spice.displayDevice == "qxl" && vmCfg.spice.vgamem != null then "-vga none -device qxl-vga,vgamem_mb=${toString vmCfg.spice.vgamem}" else "-vga ${vmCfg.spice.displayDevice}")} \ ${optionalString (vmCfg.spice.enable && vmCfg.spice.agent.enable) "-device virtio-serial-pci -chardev spicevmc,id=vdagent,debug=0,name=vdagent -device virtserialport,chardev=vdagent,name=com.redhat.spice.0"} \ ${# Guest agent channel — prevents qemu-ga from spinning when virtio-win guest tools are installed optionalString isWindows "${optionalString (!vmCfg.spice.enable || !vmCfg.spice.agent.enable) "-device virtio-serial-pci"} -chardev socket,path=/tmp/qga-${vmCfg.name}.sock,server=on,wait=off,id=qga0 -device virtserialport,chardev=qga0,name=org.qemu.guest_agent.0"} \ diff --git a/nixos/vms/submoduleOptions.nix b/nixos/vms/submoduleOptions.nix index 5dcca25..e871ca1 100644 --- a/nixos/vms/submoduleOptions.nix +++ b/nixos/vms/submoduleOptions.nix @@ -97,6 +97,11 @@ with lib; default = "qxl"; description = "QEMU -vga type to use with SPICE (qxl, virtio, std, none)."; }; + vgamem = mkOption { + type = types.nullOr types.int; + default = null; + description = "Video memory in MB for QXL device. When set, uses -device qxl-vga instead of -vga qxl."; + }; }; nographic = mkOption { type = types.bool;