2021-06-28 23:13:55 +00:00
|
|
|
{ stdenv
|
|
|
|
, config
|
|
|
|
, lib
|
|
|
|
, fetchFromGitHub
|
|
|
|
, fetchpatch
|
|
|
|
, cmake
|
|
|
|
, libusb1
|
|
|
|
, ninja
|
|
|
|
, pkg-config
|
|
|
|
, gcc
|
2022-08-12 12:06:08 +00:00
|
|
|
, mesa
|
|
|
|
, gtk3
|
|
|
|
, glfw
|
|
|
|
, libGLU
|
|
|
|
, curl
|
2023-08-04 22:07:22 +00:00
|
|
|
, cudaSupport ? config.cudaSupport, cudaPackages ? { }
|
2021-06-28 23:13:55 +00:00
|
|
|
, enablePython ? false, pythonPackages ? null
|
2022-08-12 12:06:08 +00:00
|
|
|
, enableGUI ? false,
|
2021-06-28 23:13:55 +00:00
|
|
|
}:
|
2020-08-20 17:08:02 +00:00
|
|
|
|
2022-04-15 01:41:22 +00:00
|
|
|
assert cudaSupport -> (cudaPackages?cudatoolkit && cudaPackages.cudatoolkit != null);
|
2020-08-20 17:08:02 +00:00
|
|
|
assert enablePython -> pythonPackages != null;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
stdenv.mkDerivation rec {
|
|
|
|
pname = "librealsense";
|
2024-01-02 11:29:13 +00:00
|
|
|
version = "2.54.2";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
outputs = [ "out" "dev" ];
|
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "IntelRealSense";
|
|
|
|
repo = pname;
|
|
|
|
rev = "v${version}";
|
2024-01-02 11:29:13 +00:00
|
|
|
sha256 = "sha256-EbnIHnsUgsqN/SVv4m9H7K8gfwni+u82+M55QBstAGI=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
buildInputs = [
|
|
|
|
libusb1
|
2020-08-20 17:08:02 +00:00
|
|
|
gcc.cc.lib
|
2022-04-15 01:41:22 +00:00
|
|
|
] ++ lib.optional cudaSupport cudaPackages.cudatoolkit
|
2022-08-12 12:06:08 +00:00
|
|
|
++ lib.optionals enablePython (with pythonPackages; [ python pybind11 ])
|
|
|
|
++ lib.optionals enableGUI [ mesa gtk3 glfw libGLU curl ];
|
2020-08-20 17:08:02 +00:00
|
|
|
|
2021-06-28 23:13:55 +00:00
|
|
|
patches = [
|
2021-05-20 23:08:51 +00:00
|
|
|
./py_pybind11_no_external_download.patch
|
2024-01-02 11:29:13 +00:00
|
|
|
./install-presets.patch
|
2024-01-25 14:12:00 +00:00
|
|
|
# https://github.com/IntelRealSense/librealsense/pull/11917
|
|
|
|
(fetchpatch {
|
|
|
|
name = "fix-gcc13-missing-cstdint.patch";
|
|
|
|
url = "https://github.com/IntelRealSense/librealsense/commit/b59b13671658910fc453a4a6bbd61f13ba6e83cc.patch";
|
|
|
|
hash = "sha256-zaW8HG8rfsApI5S/3x+x9Fx8xhyTIPNn/fJVFtkmlEA=";
|
|
|
|
})
|
2020-04-24 23:36:52 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
nativeBuildInputs = [
|
|
|
|
cmake
|
|
|
|
ninja
|
2021-01-09 10:05:03 +00:00
|
|
|
pkg-config
|
2020-04-24 23:36:52 +00:00
|
|
|
];
|
|
|
|
|
2020-08-20 17:08:02 +00:00
|
|
|
cmakeFlags = [
|
|
|
|
"-DBUILD_EXAMPLES=ON"
|
2022-08-12 12:06:08 +00:00
|
|
|
"-DBUILD_GRAPHICAL_EXAMPLES=${lib.boolToString enableGUI}"
|
|
|
|
"-DBUILD_GLSL_EXTENSIONS=${lib.boolToString enableGUI}"
|
|
|
|
"-DCHECK_FOR_UPDATES=OFF" # activated by BUILD_GRAPHICAL_EXAMPLES, will make it download and compile libcurl
|
2020-08-20 17:08:02 +00:00
|
|
|
] ++ lib.optionals enablePython [
|
|
|
|
"-DBUILD_PYTHON_BINDINGS:bool=true"
|
|
|
|
"-DXXNIX_PYTHON_SITEPACKAGES=${placeholder "out"}/${pythonPackages.python.sitePackages}"
|
|
|
|
] ++ lib.optional cudaSupport "-DBUILD_WITH_CUDA:bool=true";
|
|
|
|
|
|
|
|
# ensure python package contains its __init__.py. for some reason the install
|
|
|
|
# script does not do this, and it's questionable if intel knows it should be
|
|
|
|
# done
|
|
|
|
# ( https://github.com/IntelRealSense/meta-intel-realsense/issues/20 )
|
2023-07-15 17:15:38 +00:00
|
|
|
postInstall = ''
|
|
|
|
substituteInPlace $out/lib/cmake/realsense2/realsense2Targets.cmake \
|
2024-05-15 15:35:15 +00:00
|
|
|
--replace-fail "\''${_IMPORT_PREFIX}/include" "$dev/include"
|
2023-07-15 17:15:38 +00:00
|
|
|
'' + lib.optionalString enablePython ''
|
2020-08-20 17:08:02 +00:00
|
|
|
cp ../wrappers/python/pyrealsense2/__init__.py $out/${pythonPackages.python.sitePackages}/pyrealsense2
|
|
|
|
'';
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2021-02-05 17:12:51 +00:00
|
|
|
meta = with lib; {
|
2024-06-20 14:57:18 +00:00
|
|
|
description = "Cross-platform library for Intel® RealSense™ depth cameras (D400 series and the SR300)";
|
2020-04-24 23:36:52 +00:00
|
|
|
homepage = "https://github.com/IntelRealSense/librealsense";
|
|
|
|
license = licenses.asl20;
|
2022-08-12 12:06:08 +00:00
|
|
|
maintainers = with maintainers; [ brian-dawn pbsds ];
|
2021-06-28 23:13:55 +00:00
|
|
|
platforms = platforms.unix;
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
}
|