2021-01-09 10:05:03 +00:00
|
|
|
{ stdenv, config, lib, fetchFromGitHub, cmake, libusb1, ninja, pkg-config, gcc
|
2020-08-20 17:08:02 +00:00
|
|
|
, cudaSupport ? config.cudaSupport or false, cudatoolkit
|
|
|
|
, enablePython ? false, pythonPackages ? null }:
|
|
|
|
|
|
|
|
assert cudaSupport -> cudatoolkit != null;
|
|
|
|
assert enablePython -> pythonPackages != null;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
stdenv.mkDerivation rec {
|
|
|
|
pname = "librealsense";
|
2021-02-19 19:06:45 +00:00
|
|
|
version = "2.42.0";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
outputs = [ "out" "dev" ];
|
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "IntelRealSense";
|
|
|
|
repo = pname;
|
|
|
|
rev = "v${version}";
|
2021-02-19 19:06:45 +00:00
|
|
|
sha256 = "sha256-8r8j0g7EaSUWujX+BNdkIJhzaLITMLsozjhOtQBriTA=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
buildInputs = [
|
|
|
|
libusb1
|
2020-08-20 17:08:02 +00:00
|
|
|
gcc.cc.lib
|
|
|
|
] ++ lib.optional cudaSupport cudatoolkit
|
|
|
|
++ lib.optional enablePython pythonPackages.python;
|
|
|
|
|
|
|
|
patches = lib.optionals enablePython [
|
|
|
|
./py_sitepackage_dir.patch
|
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"
|
|
|
|
"-DBUILD_GRAPHICAL_EXAMPLES=OFF"
|
|
|
|
"-DBUILD_GLSL_EXTENSIONS=OFF"
|
|
|
|
] ++ 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 )
|
|
|
|
postInstall = lib.optionalString enablePython ''
|
|
|
|
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; {
|
2020-04-24 23:36:52 +00:00
|
|
|
description = "A cross-platform library for Intel® RealSense™ depth cameras (D400 series and the SR300)";
|
|
|
|
homepage = "https://github.com/IntelRealSense/librealsense";
|
|
|
|
license = licenses.asl20;
|
|
|
|
maintainers = with maintainers; [ brian-dawn ];
|
|
|
|
platforms = [ "i686-linux" "x86_64-linux" "x86_64-darwin" ];
|
|
|
|
};
|
|
|
|
}
|