16 , cudaSupport ? config.cudaSupport or false, 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 = "0aqf48zl7825v7x8c3x5w4d17m4qq377f1mn6xyqzf9b0dnk4i1j";
40 ] ++ lib.optional cudaSupport cudaPackages.cudatoolkit
41 ++ lib.optionals enablePython (with pythonPackages; [ python pybind11 ])
42 ++ lib.optionals enableGUI [ mesa gtk3 glfw libGLU curl ];
45 # fix build on aarch64-darwin
46 # https://github.com/IntelRealSense/librealsense/pull/9253
48 url = "https://github.com/IntelRealSense/librealsense/commit/beb4c44debc8336de991c983274cad841eb5c323.patch";
49 sha256 = "05mxsd2pz3xrvywdqyxkwdvxx8hjfxzcgl51897avz4v2j89pyq8";
51 ./py_sitepackage_dir.patch
52 ./py_pybind11_no_external_download.patch
63 "-DBUILD_GRAPHICAL_EXAMPLES=${lib.boolToString enableGUI}"
64 "-DBUILD_GLSL_EXTENSIONS=${lib.boolToString enableGUI}"
65 "-DCHECK_FOR_UPDATES=OFF" # activated by BUILD_GRAPHICAL_EXAMPLES, will make it download and compile libcurl
66 ] ++ lib.optionals enablePython [
67 "-DBUILD_PYTHON_BINDINGS:bool=true"
68 "-DXXNIX_PYTHON_SITEPACKAGES=${placeholder "out"}/${pythonPackages.python.sitePackages}"
69 ] ++ lib.optional cudaSupport "-DBUILD_WITH_CUDA:bool=true";
71 # ensure python package contains its __init__.py. for some reason the install
72 # script does not do this, and it's questionable if intel knows it should be
74 # ( https://github.com/IntelRealSense/meta-intel-realsense/issues/20 )
75 postInstall = lib.optionalString enablePython ''
76 cp ../wrappers/python/pyrealsense2/__init__.py $out/${pythonPackages.python.sitePackages}/pyrealsense2
80 description = "A cross-platform library for IntelĀ® RealSenseā¢ depth cameras (D400 series and the SR300)";
81 homepage = "https://github.com/IntelRealSense/librealsense";
82 license = licenses.asl20;
83 maintainers = with maintainers; [ brian-dawn pbsds ];
84 platforms = platforms.unix;