Wayland compositors an build-vm not working

Hi,
I wanted to start my hyprland configuration and wanted to use the build-vm function so I can test out until I have a stable enough configuration, but I found a problem that I could not solve.
When trying to run the vm I get a black screen and after a short while I am logged out. When I log in with my user I see the black screen again and I am logged out again. When I start Hyprland from the tty. I get an error saying that “Could not successfully create backend on any GPU”.


Although It seems there is some GPU:

Here is the minimum configuration needed to replicate:

flake.nix
{
  description = "A very basic flake";

  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.11";
  };

  outputs = { self, nixpkgs }: {

	nixosConfigurations = {
	  desktop = nixpkgs.lib.nixosSystem {
		system = "x86_64";
		modules = [
		  ./configuration.nix
		];
	  };
	};
  };
}
configuration.nix
{ config, lib, pkgs, ... }:

{
  imports =
    [ # Include the results of the hardware scan.
      ./hardware-configuration.nix
    ];
  boot.loader.grub.enable = true;

  services.xserver.enable = true;
  # Enable the Plasma 5 Desktop Environment.
  services.xserver.displayManager.sddm.enable = true;
  services.xserver.desktopManager.plasma5.enable = true;
  services.xserver.displayManager.defaultSession = "hyprland";
  services.openssh = {
	enable = true;
	passwordAuthentication = true;
  };
  programs.hyprland = {
	enable = true;
	xwayland.enable = true;
  };
  
  # Configure keymap in X11
  services.xserver.xkb.layout = "us";
  # services.xserver.xkb.options = "eurosign:e,caps:escape";

  # Define a user account. Don't forget to set a password with ‘passwd’.
  users.users.test = {
	isNormalUser = true;
	initialPassword = "test";
    extraGroups = [ "wheel" ]; # Enable ‘sudo’ for the user.
    packages = with pkgs; [
	  firefox
      tree
    ];
  };

  # List packages installed in system profile. To search, run:
  # $ nix search wget
  environment.systemPackages = with pkgs; [
	vim
    wget
  ];

  system.stateVersion = "23.05"; 
}

and I use

nixos-rebuild build-vm --flake .#desktop && ./result/bin/run-nixos-vm

to run the vm.
I have tried sway, but it does the same thing.
plasmawayland seems to work, but I don’t know if it just fallbacks to x11.
The system I use is ryzen 2600 and AMD rx580.

Yeah I had some issue getting this running myself, but it’s possible.

Within my nixosConfiguration I’m using

virtualisation.vmVariant = {
  # Taken from https://github.com/donovanglover/nix-config/commit/0bf134297b3a62da62f9ee16439d6da995d3fbff
  # to enable Hyprland to work on a virtualized GPU.
  virtualisation.qemu.options = [
    "-device virtio-vga-gl"
    "-display sdl,gl=on,show-cursor=off"
     # Wire up pipewire audio
    "-audiodev pipewire,id=audio0"
    "-device intel-hda"
    "-device hda-output,audiodev=audio0"
  ];

  environment.sessionVariables = nixLib.mkVMOverride {
    WLR_NO_HARDWARE_CURSORS = "1";
};

to adjust specific options only for build.system.vm - they won’t get applied when building build.system.toplevel aka the normal system config.

[EDIT]
For a while I used to have issues with hyprland being started up via sddm in the VM. Not sure since which commit, but it has been fixed in nixpkgs-unstable a few months ago.