Creating a cuda-enabled development environment for machine learning on NixOS

Hi, I just got started with NixOS and I’m trying to set up an environment to do machine learning development, for which I need cuda. I managed to get the libraries I need working globally on my system but now I need a development system where I can install packages using pip install. Any suggestions?

Here’s what I tried:

I found the following flake from For those on NixOS, here's a quick and dirty flake.nix that will let you make a ... | Hacker News
and modified it to upgrade the python version. That failed however while building cuda-11. On my system, I’m using cuda-12 so I tried putting cudaVersion = “12”. But apparently, this is being ignored since when I run nix develop and it fails again for the same reason. Here’s the erro I get:

[5/0/16 built, 0.0 MiB DL] building magma-2.7.1 (buildPhase): [310/3430] Building CUDA object CMakeFiles/magma.dir/magmablas/zlerror: builder for '/nix/store/' failed with exit code 1;
       last 7 log lines:
       > trying
       >   % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
       >                                  Dload  Upload   Total   Spent    Left  Speed
       >  96 4135M   96 3970M    0     0  2716k      0  0:25:58  0:24:56  0:01:02     0
       > curl: (56) Recv failure: Connection reset by peer
       > error: cannot download from any mirror
       For full logs, run 'nix log /nix/store/'.
error: 1 dependencies of derivation '/nix/store/30x24ks6413y06wby7wqng88x3j0aqrg-cudatoolkit-11.8.0.drv' failed to build
error: 1 dependencies of derivation '/nix/store/1lg7if7a5wqfyh69i5scq1fd05aqmigp-nix-shell-env.drv' failed to build

Below you can find the whole flake.nix I’m trying to install:

And my configuration.nix where I have cuda-12:

Also building that flake is extremely slow. Are there alternatives?