okami.mom/strata

git clone https://git.nkp.pet/okami.mom/strata

Coby Tamayorm git depe8b455117

main
1.7 KiB49 linesraw
1{
2  description = "Nix environment for Strata";
3
4  inputs = {
5    nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
6  };
7
8  outputs = { self, nixpkgs, ... }:
9    let
10      system = "x86_64-linux";
11      pkgs = import nixpkgs {
12        inherit system;
13        # Allow NVIDIA's CUDA toolkit (nvcc, cudart, cuBLAS, ...).
14        config.allowUnfree = true;
15        config.cudaSupport = true;
16      };
17
18      # setup.py wants CUDA 13.0: the ready-made engine is built with 13.0.88, and 13.2.0/13.2.1 miscompile for sm_120.
19      cudaPackages = pkgs.cudaPackages_13_0;
20      # One merged toolkit root (bin/nvcc, include/, lib/ with cudart and cuBLAS) for CUDA_HOME / CUDAToolkit_ROOT.
21      cuda = cudaPackages.cudatoolkit;
22      # The gcc that this nvcc supports as its host compiler.
23      stdenv = cudaPackages.backendStdenv;
24
25    in
26    {
27      devShells."${system}" = {
28        default = (pkgs.mkShell.override { inherit stdenv; }) {
29          packages = with pkgs; [
30            # ./setup.sh: makes .venv and runs setup.py
31            python3
32
33            # setup.py's engine build. cmake/ninja from PATH: the pip wheels' binaries do not run on NixOS.
34            cuda
35            cmake
36            ninja
37          ];
38
39          shellHook = ''
40            export CUDA_HOME=${cuda}
41            export CUDA_PATH=${cuda}
42            export CUDAHOSTCXX=${stdenv.cc}/bin/c++
43            # The pip wheels in .venv (numpy, pillow, ...) need libstdc++ and zlib; the engine needs the driver's libcuda.
44            export LD_LIBRARY_PATH=/run/opengl-driver/lib:${pkgs.lib.makeLibraryPath [ stdenv.cc.cc.lib pkgs.zlib ]}''${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}
45          '';
46        };
47      };
48    };
49}