16 , cudaSupport ? config.cudaSupport, cudaPackages ? { }
17 , enablePython ? false, pythonPackages ? null
21 assert cudaSupport -> (cudaPackages?cudatoolkit && cudaPackages.cudatoolkit != null);
22 assert enablePython -> pythonPackages != null;
24 stdenv.mkDerivation rec {
25 pname = "librealsense";
28 outputs = [ "out" "dev" ];
30 src = fetchFromGitHub {
31 owner = "IntelRealSense";
34 sha256 = "sha256-7DO+AC9R6mnSs52ex/uIzEv7q+fS7FQ5FGYe5niap4Q=";
41 ] ++ lib.optionals cudaSupport [ cudaPackages.cuda_cudart ]
42 ++ lib.optionals enablePython (with pythonPackages; [ python pybind11 ])
43 ++ lib.optionals enableGUI [ mesa gtk3 glfw libGLU curl ];
46 ./py_pybind11_no_external_download.patch
47 ./install-presets.patch
51 # use nixpkgs nlohmann_json instead of fetching it
52 substituteInPlace third-party/CMakeLists.txt \
54 'include(CMake/external_json.cmake)' \
55 'find_package(nlohmann_json 3.11.3 REQUIRED)'
62 ] ++ lib.optionals cudaSupport [
63 cudaPackages.cuda_nvcc
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
79 # ( https://github.com/IntelRealSense/meta-intel-realsense/issues/20 )
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
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;