Packaging python app with pyside and opengl woes

I’m trying to package a python pyside6 app that also uses pyopengl in QOpenGLWidget

python311Packages.buildPythonApplication {
  name = "testapp";
  pyproject = true;
  src = ./.;

  build-system = with python311Packages; [ setuptools ];

  buildInputs = [
    qt6.qtbase
    qt6.qtwayland
  ];
  nativeBuildInputs = [
    qt6.wrapQtAppsHook
  ];
  dontWrapQtApps = true;
  makeWrapperArgs = [
    "\${qtWrapperArgs[@]}"
  ];

  dependencies = with python311Packages; [
    glfw
    pyopengl
    pyside6
    lz4
    grandalf
    numpy_1
  ]
}


This builds, but crashes on start with

qt.qpa.wayland: EGL not available
QOpenGLWidget is not supported on this platform
...
Aborted                    (core dumped)

if I run the same with QT_QPA_PLATFORM=xcb - then everythin QT related works, but pyopengl has issues:

  File "/nix/store/2k7q01jyq654fy0pi4zxbkmhlcyhlcps-python3.11-imgui/lib/python3.11/site-packages/imgui/integrations/opengl.py", line 60, in __init__
    super(ProgrammablePipelineRenderer, self).__init__()
  File "/nix/store/2k7q01jyq654fy0pi4zxbkmhlcyhlcps-python3.11-imgui/lib/python3.11/site-packages/imgui/integrations/base.py", line 17, in __init__
    self._create_device_objects()
  File "/nix/store/2k7q01jyq654fy0pi4zxbkmhlcyhlcps-python3.11-imgui/lib/python3.11/site-packages/imgui/integrations/opengl.py", line 125, in _create_device_objects
    gl.glVertexAttribPointer(self._attrib_location_position, 2, gl.GL_FLOAT, gl.GL_FALSE, imgui.VERTEX_SIZE, ctypes.c_void_p(imgui.VERTEX_BUFFER_POS_OFFSET))
  File "/nix/store/pq4dyz2gz5l8m43vyv54lqva3kkwkzyn-python3.11-pyopengl-3.1.9/lib/python3.11/site-packages/OpenGL/latebind.py", line 63, in __call__
    return self.wrapperFunction( self.baseFunction, *args, **named )
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/nix/store/pq4dyz2gz5l8m43vyv54lqva3kkwkzyn-python3.11-pyopengl-3.1.9/lib/python3.11/site-packages/OpenGL/GL/VERSION/GL_2_0.py", line 465, in glVertexAttribPointer
    contextdata.setValue( key, array )
  File "/nix/store/pq4dyz2gz5l8m43vyv54lqva3kkwkzyn-python3.11-pyopengl-3.1.9/lib/python3.11/site-packages/OpenGL/contextdata.py", line 58, in setValue
    context = getContext( context )
              ^^^^^^^^^^^^^^^^^^^^^
  File "/nix/store/pq4dyz2gz5l8m43vyv54lqva3kkwkzyn-python3.11-pyopengl-3.1.9/lib/python3.11/site-packages/OpenGL/contextdata.py", line 40, in getContext
    raise error.Error(
OpenGL.error.Error: Attempt to retrieve context when no valid context

I can also remove the whole

  buildInputs = [
    qt6.qtbase
    qt6.qtwayland
  ];
  nativeBuildInputs = [
    qt6.wrapQtAppsHook
  ];
  dontWrapQtApps = true;
  makeWrapperArgs = [
    "\${qtWrapperArgs[@]}"
  ];

part, and it still builds, but seemingly without wayland support, and runs with xwayland without any extra env vars specified, but with the same opengl error.

What am I doing wrong here?