Correct way for setting up spice and qxl in a vm

I’d like to build a vm using nixos-rebuild build-vm to test my configuration or some arbitrary program. The graphic interface is a little choppy so I want some acceleration. I add these lines to configuration when building a vm:

{ config, lib, pkgs, ... }: 
let
  mkSure = lib.mkOverride 0;
in
{
  environment.systemPackages = [
    pkgs.xorg.xf86videoqxl
  ];
  services.xserver.videoDrivers = [ "qxl" ];
  services.spice-vdagentd.enable = mkSure true;
  virtualisation.qemu.options = [ "-vga qxl" ];
  virtualisation.memorySize = 8192;
  virtualisation.cores = 6;
}

but this causes problems: when the mouse pointer is moved into the vm’s windows, the host’s xserver crashes immediately. Do you have any clues?

P.S. when building the vm, I get this error:

error: The option virtualisation.cores' defined in /home/mlatus/.config/nixpkgs/nixos/trigger-vm.nix’ does not exist.

but the vm is still successfully built.

1 Like

Caused by nvidia driver, oops…