Remove n0emis as direct maintainer (#365023)
[NixPkgs.git] / pkgs / development / libraries / librealsense / default.nix
blobef311bdd0246035099a814b6b32f5c12e21b9a01
1 { stdenv
2 , config
3 , lib
4 , fetchFromGitHub
5 , cmake
6 , libusb1
7 , nlohmann_json
8 , ninja
9 , pkg-config
10 , gcc
11 , mesa
12 , gtk3
13 , glfw
14 , libGLU
15 , curl
16 , cudaSupport ? config.cudaSupport, cudaPackages ? { }
17 , enablePython ? false, pythonPackages ? null
18 , enableGUI ? false,
21 assert cudaSupport -> (cudaPackages?cudatoolkit && cudaPackages.cudatoolkit != null);
22 assert enablePython -> pythonPackages != null;
24 stdenv.mkDerivation rec {
25   pname = "librealsense";
26   version = "2.56.2";
28   outputs = [ "out" "dev" ];
30   src = fetchFromGitHub {
31     owner = "IntelRealSense";
32     repo = pname;
33     rev = "v${version}";
34     sha256 = "sha256-7DO+AC9R6mnSs52ex/uIzEv7q+fS7FQ5FGYe5niap4Q=";
35   };
37   buildInputs = [
38     libusb1
39     gcc.cc.lib
40     nlohmann_json
41   ] ++ lib.optionals cudaSupport [ cudaPackages.cuda_cudart ]
42     ++ lib.optionals enablePython (with pythonPackages; [ python pybind11 ])
43     ++ lib.optionals enableGUI [ mesa gtk3 glfw libGLU curl ];
45   patches = [
46     ./py_pybind11_no_external_download.patch
47     ./install-presets.patch
48   ];
50   postPatch = ''
51     # use nixpkgs nlohmann_json instead of fetching it
52     substituteInPlace third-party/CMakeLists.txt \
53       --replace-fail \
54         'include(CMake/external_json.cmake)' \
55         'find_package(nlohmann_json 3.11.3 REQUIRED)'
56   '';
58   nativeBuildInputs = [
59     cmake
60     ninja
61     pkg-config
62   ] ++ lib.optionals cudaSupport [
63     cudaPackages.cuda_nvcc
64   ];
66   cmakeFlags = [
67     "-DBUILD_EXAMPLES=ON"
68     "-DBUILD_GRAPHICAL_EXAMPLES=${lib.boolToString enableGUI}"
69     "-DBUILD_GLSL_EXTENSIONS=${lib.boolToString enableGUI}"
70     "-DCHECK_FOR_UPDATES=OFF" # activated by BUILD_GRAPHICAL_EXAMPLES, will make it download and compile libcurl
71   ] ++ lib.optionals enablePython [
72     "-DBUILD_PYTHON_BINDINGS:bool=true"
73     "-DXXNIX_PYTHON_SITEPACKAGES=${placeholder "out"}/${pythonPackages.python.sitePackages}"
74   ] ++ lib.optional cudaSupport "-DBUILD_WITH_CUDA:bool=true";
76   # ensure python package contains its __init__.py. for some reason the install
77   # script does not do this, and it's questionable if intel knows it should be
78   # done
79   # ( https://github.com/IntelRealSense/meta-intel-realsense/issues/20 )
80   postInstall = ''
81     substituteInPlace $out/lib/cmake/realsense2/realsense2Targets.cmake \
82     --replace-fail "\''${_IMPORT_PREFIX}/include" "$dev/include"
83   '' + lib.optionalString enablePython  ''
84     cp ../wrappers/python/pyrealsense2/__init__.py $out/${pythonPackages.python.sitePackages}/pyrealsense2
85   '';
87   meta = with lib; {
88     description = "Cross-platform library for IntelĀ® RealSenseā„¢ depth cameras (D400 series and the SR300)";
89     homepage = "https://github.com/IntelRealSense/librealsense";
90     license = licenses.asl20;
91     maintainers = with maintainers; [ brian-dawn pbsds ];
92     platforms = platforms.unix;
93   };