Creating a Cudatoolkit shell, env or flake

I tried multiple approaches until now to create an environment or for the beginning a shell should be sufficient, which provides a cuda Installation. The first attempt with tensorflowWithCuda failed with to less memory a few days ago. So I decided to try another approach and begun with the shell.nix from CUDA - NixOS Wiki which seem to work on the first approach, but after installing tensorflow inside a venv gpu is not recognized.

Ok so I tried a flake which I found on reddit. It seems ok but uses already poetry which I don’t want provide for my users at this stage. But it failed with an error message while building cudatoolkit. I tried again the tensorflowWithCuda on a more beefy station and same Error as in the flake:

error: builder for '/nix/store/7jamnh5ggc8g050s9l1pnx05dy3kh96w-cudatoolkit-11.8.0.drv' failed with exit code 143;
       last 10 log lines:
       > Sourcing auto-add-opengl-runpath-hook
       > Using autoAddOpenGLRunpathPhase
       > Sourcing setup-cuda-hook
       > Executing setupCUDAToolkitCompilers
       > qtPreHook
       > unpacking sources
       > Creating directory pkg
       > /nix/store/pnjyl1yrlw63vypaypnp948gir430fk6-cuda_11.8.0_520.61.05_linux.run: line 226: /dev/tty: No such device or address
       > /nix/store/pnjyl1yrlw63vypaypnp948gir430fk6-cuda_11.8.0_520.61.05_linux.run: line 226: /dev/tty: No such device or address
       > Terminated
       For full logs, run 'nix-store -l /nix/store/7jamnh5ggc8g050s9l1pnx05dy3kh96w-cudatoolkit-11.8.0.drv'.
       note: build failure may have been caused by lack of free disk space
error: 1 dependencies of derivation '/nix/store/l6z16cb3pn878898j726m6x231wls7h1-python3.10-tensorflow-gpu-2.11.1.drv' failed to build

What might cause this issue? And how to do this properly? It is fine for me to build Cuda and provide binary caches, which than can be used by my users.