Run qt app from flake

I try to start sclang of supercollider from a flake it seems it need qt to run.
How do I pass those information into a flake?

When sclang started from a flake it fails with the following output:

warning: creating lock file '/home/olaf/github/qtflake/flake.lock'
compiling class library...
qt.qpa.plugin: Could not find the Qt platform plugin "wayland" in ""
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.

Available platform plugins are: eglfs, linuxfb, minimal, minimalegl, offscreen, vnc, xcb.

/nix/store/ariv3k47kf8k782bjkfaziiy49p1k36r-test/bin/test: line 8: 406414 Aborted                 (core dumped) sclang

so it seems i need to pass some information regarding qt and wayland from my system to the shell that runs sclang.

here is the flake:


  description = "test";

  inputs = {
    nixpkgs.url = "github:nixOS/nixpkgs";
    flake-utils.url = "github:numtide/flake-utils";

  outputs = { self, nixpkgs, flake-utils }:
    flake-utils.lib.eachDefaultSystem (system:
        pkgs = import nixpkgs { inherit system; };
        packages.test = pkgs.writeShellApplication {
          name = "test";
          runtimeInputs = with pkgs; [ supercollider ];
          text = ''

        apps.default = {
          type = "app";
          program = "${self.packages.${system}.test}/bin/test";

Maybe one can rephrase the question to: How do I get current environment variables into a flake?

problem disappeared after changing nixpkgs to stable 22.11
the problem seems to appear only when i use a different version in the flake then i use on my system.
when i use the latest nixpkgs i could resolve the problem by setting
which is ok for my usecase