Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{ 2 lib, 3 stdenv, 4 cmake, 5 ninja, 6 fetchFromGitHub, 7 python3, 8 opencv, 9 nlohmann_json, 10 nanoflann, 11 glm, 12 cxxopts, 13 nix-update-script, 14 config, 15 # Upstream has rocm/hip support, too. anyone? 16 cudaSupport ? config.cudaSupport, 17 cudaPackages, 18 autoAddDriverRunpath, 19 fetchpatch2, 20}: 21let 22 version = "1.1.4"; 23 torch = python3.pkgs.torch.override { inherit cudaSupport; }; 24 # Using a normal stdenv with cuda torch gives 25 # ld: /nix/store/k1l7y96gv0nc685cg7i3g43i4icmddzk-python3.11-torch-2.2.1-lib/lib/libc10.so: undefined reference to `std::ios_base_library_init()@GLIBCXX_3.4.32' 26 stdenv' = if cudaSupport then cudaPackages.backendStdenv else stdenv; 27in 28stdenv'.mkDerivation { 29 pname = "opensplat"; 30 inherit version; 31 32 src = fetchFromGitHub { 33 owner = "pierotofy"; 34 repo = "OpenSplat"; 35 tag = "v${version}"; 36 hash = "sha256-u2UmD0O3sUWELYb4CjQE19i4HUjLMcaWqOinQH0PPTM="; 37 }; 38 39 patches = [ 40 (fetchpatch2 { 41 url = "https://github.com/pierotofy/OpenSplat/commit/7fb96e86a43ac6cfd3eb3a7f6be190c5f2dbeb73.patch"; 42 hash = "sha256-hWJWU/n1pRAAbExAYUap6CoSjIu2dzCToUmacSSpa0I="; 43 }) 44 ]; 45 46 nativeBuildInputs = [ 47 cmake 48 ninja 49 ] 50 ++ lib.optionals cudaSupport [ 51 cudaPackages.cuda_nvcc 52 autoAddDriverRunpath 53 ]; 54 55 buildInputs = [ 56 nlohmann_json 57 nanoflann 58 glm 59 cxxopts 60 torch.cxxdev 61 torch 62 opencv 63 ] 64 ++ lib.optionals cudaSupport [ 65 cudaPackages.cuda_cudart 66 ]; 67 68 env.TORCH_CUDA_ARCH_LIST = "${lib.concatStringsSep ";" python3.pkgs.torch.cudaCapabilities}"; 69 70 cmakeFlags = [ 71 (lib.cmakeBool "CMAKE_SKIP_RPATH" true) 72 (lib.cmakeFeature "FETCHCONTENT_TRY_FIND_PACKAGE_MODE" "ALWAYS") 73 ] 74 ++ lib.optionals cudaSupport [ 75 (lib.cmakeFeature "GPU_RUNTIME" "CUDA") 76 (lib.cmakeFeature "CUDA_TOOLKIT_ROOT_DIR" "${cudaPackages.cudatoolkit}/") 77 ]; 78 79 passthru.updateScript = nix-update-script { }; 80 81 meta = { 82 description = "Production-grade 3D gaussian splatting"; 83 homepage = "https://github.com/pierotofy/OpenSplat/"; 84 license = [ 85 # main 86 lib.licenses.agpl3Only 87 # vendored+modified gsplat 88 lib.licenses.asl20 89 ]; 90 maintainers = [ lib.maintainers.jcaesar ]; 91 platforms = lib.platforms.linux ++ lib.optionals (!cudaSupport) lib.platforms.darwin; 92 }; 93}