azure-storage-azcopy: 10.27.1 -> 10.28.0 (#377459)
[NixPkgs.git] / pkgs / by-name / op / opensplat / package.nix
blob6dbe03103e2162a1090945d200f88af8bc3b42d4
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,
20 let
21   version = "1.1.4";
22   torch = python3.pkgs.torch.override { inherit cudaSupport; };
23   # Using a normal stdenv with cuda torch gives
24   # 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'
25   stdenv' = if cudaSupport then cudaPackages.backendStdenv else stdenv;
27 stdenv'.mkDerivation {
28   pname = "opensplat";
29   inherit version;
31   src = fetchFromGitHub {
32     owner = "pierotofy";
33     repo = "OpenSplat";
34     tag = "v${version}";
35     hash = "sha256-u2UmD0O3sUWELYb4CjQE19i4HUjLMcaWqOinQH0PPTM=";
36   };
38   nativeBuildInputs =
39     [
40       cmake
41       ninja
42     ]
43     ++ lib.optionals cudaSupport [
44       cudaPackages.cuda_nvcc
45       autoAddDriverRunpath
46     ];
48   buildInputs =
49     [
50       nlohmann_json
51       nanoflann
52       glm
53       cxxopts
54       torch.cxxdev
55       torch
56       opencv
57     ]
58     ++ lib.optionals cudaSupport [
59       cudaPackages.cuda_cudart
60     ];
62   env.TORCH_CUDA_ARCH_LIST = "${lib.concatStringsSep ";" python3.pkgs.torch.cudaCapabilities}";
64   cmakeFlags =
65     [
66       (lib.cmakeBool "CMAKE_SKIP_RPATH" true)
67       (lib.cmakeFeature "FETCHCONTENT_TRY_FIND_PACKAGE_MODE" "ALWAYS")
68     ]
69     ++ lib.optionals cudaSupport [
70       (lib.cmakeFeature "GPU_RUNTIME" "CUDA")
71       (lib.cmakeFeature "CUDA_TOOLKIT_ROOT_DIR" "${cudaPackages.cudatoolkit}/")
72     ];
74   passthru.updateScript = nix-update-script { };
76   meta = {
77     description = "Production-grade 3D gaussian splatting";
78     homepage = "https://github.com/pierotofy/OpenSplat/";
79     license = [
80       # main
81       lib.licenses.agpl3Only
82       # vendored+modified gsplat
83       lib.licenses.asl20
84     ];
85     maintainers = [ lib.maintainers.jcaesar ];
86     platforms = lib.platforms.linux ++ lib.optionals (!cudaSupport) lib.platforms.darwin;
87   };