Unable to turn on 3d acceleration for virtual machines

When I enable 3d acceleration in virt-manager or GNOME Boxes, I get this error:

Unable to complete install: 'internal error: QEMU unexpectedly closed the monitor (vm='supernova'): 2024-10-02T19:57:46.986782Z qemu-system-x86_64: egl: eglInitialize failed: EGL_NOT_INITIALIZED
2024-10-02T19:57:46.986888Z qemu-system-x86_64: egl: render node init failed'

Traceback (most recent call last):
  File "/usr/share/virt-manager/virtManager/asyncjob.py", line 72, in cb_wrapper
    callback(asyncjob, *args, **kwargs)
  File "/usr/share/virt-manager/virtManager/createvm.py", line 2008, in _do_async_install
    installer.start_install(guest, meter=meter)
  File "/usr/share/virt-manager/virtinst/install/installer.py", line 695, in start_install
    domain = self._create_guest(
             ^^^^^^^^^^^^^^^^^^^
  File "/usr/share/virt-manager/virtinst/install/installer.py", line 637, in _create_guest
    domain = self.conn.createXML(initial_xml or final_xml, 0)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.12/site-packages/libvirt.py", line 4529, in createXML
    raise libvirtError('virDomainCreateXML() failed')
libvirt.libvirtError: internal error: QEMU unexpectedly closed the monitor (vm='supernova'): 2024-10-02T19:57:46.986782Z qemu-system-x86_64: egl: eglInitialize failed: EGL_NOT_INITIALIZED
2024-10-02T19:57:46.986888Z qemu-system-x86_64: egl: render node init failed

This is from virt-manager; GNOME Boxes gives a much less concise error log, but it ends with the same two lines. I have been unable to find a solution in my testing. Everything was configured via ujust setup-virtualization. All help is appreciated.

Edit: it seems to be related to this issue: libvirt: openGL does not work with Nvidia GPUs · Issue #164436 · NixOS/nixpkgs · GitHub

Can confirm it to be an NVIDIA issue. Laptop has an Intel and NVIDIA GPU, fails the same way on NVIDIA but works fine on Intel. Boxes also works when I edit the VM’s XML to use the Intel GPU.