diff --git a/flake.lock b/flake.lock new file mode 100644 index 00000000..43cbb9f5 --- /dev/null +++ b/flake.lock @@ -0,0 +1,27 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1791594108, + "narHash": "sha256-XK4KceonkwD8LuMAt/vNrz982mXJM5jeHAxMwsUXXAQ=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "6510408d147d8c5e6d76043e899e9251756f6a75", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 00000000..34607fcc --- /dev/null +++ b/flake.nix @@ -0,0 +1,53 @@ +{ + description = "Nix environment for Strata"; + + inputs = { + nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; + }; + + outputs = { self, nixpkgs, ... }: + let + system = "x86_64-linux"; + pkgs = import nixpkgs { + inherit system; + # Claude Code plus NVIDIA's CUDA toolkit (nvcc, cudart, cuBLAS, ...). + config.allowUnfree = true; + config.cudaSupport = true; + }; + + # 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. + cudaPackages = pkgs.cudaPackages_13_0; + # One merged toolkit root (bin/nvcc, include/, lib/ with cudart and cuBLAS) for CUDA_HOME / CUDAToolkit_ROOT. + cuda = cudaPackages.cudatoolkit; + # The gcc that this nvcc supports as its host compiler. + stdenv = cudaPackages.backendStdenv; + + in + { + devShells."${system}" = { + # Full development environment. + default = (pkgs.mkShell.override { inherit stdenv; }) { + packages = with pkgs; [ + claude-code + + # ./setup.sh: makes .venv and runs setup.py + python3 + git + + # setup.py's engine build. cmake/ninja from PATH: the pip wheels' binaries do not run on NixOS. + cuda + cmake + ninja + ]; + + shellHook = '' + export CUDA_HOME=${cuda} + export CUDA_PATH=${cuda} + export CUDAHOSTCXX=${stdenv.cc}/bin/c++ + # The pip wheels in .venv (numpy, pillow, ...) need libstdc++ and zlib; the engine needs the driver's libcuda. + export LD_LIBRARY_PATH=/run/opengl-driver/lib:${pkgs.lib.makeLibraryPath [ stdenv.cc.cc.lib pkgs.zlib ]}''${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH} + ''; + }; + }; + }; +}