Merge pull request #329823 from ExpidusOS/fix/pkgsllvm/elfutils
[NixPkgs.git] / pkgs / by-name / op / opensplat / package.nix
blobd808a403e7bd86ba2313e30eb9cec44d7ac9c916
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.3";
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     rev = "refs/tags/v${version}";
35     hash = "sha256-2NcKb2SWU/vNsnd2KhdU85J60fJPuc44ZxIle/1UT6g=";
36   };
38   nativeBuildInputs = [
39     cmake
40     ninja
41   ] ++ lib.optionals cudaSupport [
42     cudaPackages.cuda_nvcc
43     autoAddDriverRunpath
44   ];
46   buildInputs = [
47     nlohmann_json
48     nanoflann
49     glm
50     cxxopts
51     torch.cxxdev
52     torch
53     opencv
54   ] ++ lib.optionals cudaSupport [
55     cudaPackages.cuda_cudart
56   ];
58   env.TORCH_CUDA_ARCH_LIST = "${lib.concatStringsSep ";" python3.pkgs.torch.cudaCapabilities}";
60   cmakeFlags = [
61     (lib.cmakeBool "CMAKE_SKIP_RPATH" true)
62     (lib.cmakeFeature "FETCHCONTENT_TRY_FIND_PACKAGE_MODE" "ALWAYS")
63   ] ++ lib.optionals cudaSupport [
64     (lib.cmakeFeature "GPU_RUNTIME" "CUDA")
65     (lib.cmakeFeature "CUDA_TOOLKIT_ROOT_DIR" "${cudaPackages.cudatoolkit}/")
66   ];
68   passthru.updateScript = nix-update-script { };
70   meta = {
71     description = "Production-grade 3D gaussian splatting";
72     homepage = "https://github.com/pierotofy/OpenSplat/";
73     license = [
74       # main
75       lib.licenses.agpl3Only
76       # vendored+modified gsplat
77       lib.licenses.asl20
78     ];
79     maintainers = [ lib.maintainers.jcaesar ];
80     platforms = lib.platforms.linux ++ lib.optionals (!cudaSupport) lib.platforms.darwin;
81   };