294 lines
8.6 KiB
Nix
294 lines
8.6 KiB
Nix
{
|
|
inputs = {
|
|
# Downgrade nixpkgs for working spdlog/fmt package versions
|
|
nixpkgs.url = github:NixOS/nixpkgs/8949f6984d90d3f6d16883d60ace71f04220ebb2;
|
|
|
|
xlink.url = github:luxonis/XLink/develop;
|
|
xlink.flake = false;
|
|
|
|
fp16.url = github:hunter-packages/FP16;
|
|
fp16.flake = false;
|
|
|
|
psimd.url = github:Maratyszcza/psimd;
|
|
psimd.flake = false;
|
|
|
|
libnop.url = github:luxonis/libnop/develop;
|
|
libnop.flake = false;
|
|
|
|
depthai-python.url = https://github.com/luxonis/depthai-python;
|
|
depthai-python.flake = false;
|
|
depthai-python.type = "git";
|
|
depthai-python.submodules = true;
|
|
depthai-python.ref = "refs/tags/v2.19.1.0";
|
|
|
|
depthai-sdk.url = github:luxonis/depthai/2b22e4afb94bfff6c60ddbeceaa0e20cbf170490;
|
|
depthai-sdk.flake = false;
|
|
};
|
|
|
|
outputs = { self, nixpkgs, xlink, fp16, psimd, libnop, depthai-python, depthai-sdk }:
|
|
with nixpkgs.lib;
|
|
let
|
|
systems = platforms.unix;
|
|
forAllSystems = genAttrs systems;
|
|
|
|
# Version is coupled to "depthai-core" submodule of "depthai-python":
|
|
# > cmake/Depthai/DepthaiBootloaderConfig.cmake
|
|
depthai-bootloader = builtins.fetchurl {
|
|
url = "https://artifacts.luxonis.com/artifactory/luxonis-myriad-release-local/depthai-bootloader/0.0.21/depthai-bootloader-fwp-0.0.21.tar.xz";
|
|
name = "depthai-bootloader-fwp.tar.xz";
|
|
sha256 = "0yxpdc0bbwrkjg7az07335wx1dk4n6vfa0lkawlz3d61xxaw5h57";
|
|
};
|
|
|
|
# Version is coupled to "depthai-core" submodule of "depthai-python":
|
|
# > cmake/Depthai/DepthaiDeviceSideConfig.cmake
|
|
depthai-device = builtins.fetchurl {
|
|
url = "https://artifacts.luxonis.com/artifactory/luxonis-myriad-snapshot-local/depthai-device-side/adbcc016c8bd5a5580a26d8b6250f77160203666/depthai-device-fwp-adbcc016c8bd5a5580a26d8b6250f77160203666.tar.xz";
|
|
sha256 = "191hz3d0fwmsn3vz3m98sxfsvrqs02vgq2sh6n1kz8wl04zkqg6s";
|
|
};
|
|
|
|
xlink-drv = {clangStdenv, cmake, libusb1}:
|
|
clangStdenv.mkDerivation {
|
|
name = "xlink-unstable";
|
|
src = xlink;
|
|
nativeBuildInputs = [ cmake ];
|
|
buildInputs = [ libusb1 ];
|
|
cmakeFlags = [
|
|
"-DHUNTER_ENABLED=OFF"
|
|
"-DXLINK_LIBUSB_SYSTEM=ON"
|
|
];
|
|
};
|
|
|
|
fp16-drv = { clangStdenv, cmake }:
|
|
clangStdenv.mkDerivation {
|
|
name = "fp16-unstable";
|
|
src = fp16;
|
|
nativeBuildInputs = [ cmake ];
|
|
cmakeFlags = [
|
|
"-DFP16_BUILD_TESTS=OFF"
|
|
"-DFP16_BUILD_BENCHMARKS=OFF"
|
|
"-DPSIMD_SOURCE_DIR=${psimd}"
|
|
];
|
|
};
|
|
|
|
libnop-drv = { clangStdenv, cmake, ninja, gtest }:
|
|
clangStdenv.mkDerivation {
|
|
name = "libnop-unstable";
|
|
src = libnop;
|
|
nativeBuildInputs = [ cmake ninja gtest ];
|
|
};
|
|
|
|
depthai-python-drv = {
|
|
cmake,
|
|
pkg-config,
|
|
xlink,
|
|
fp16,
|
|
libnop,
|
|
bzip2,
|
|
libarchive,
|
|
xz,
|
|
zlib,
|
|
spdlog,
|
|
nlohmann_json,
|
|
opencv,
|
|
python310Packages,
|
|
}: python310Packages.buildPythonPackage {
|
|
name = "depthai-python";
|
|
version = depthai-python.rev;
|
|
src = depthai-python;
|
|
nativeBuildInputs = [ cmake pkg-config ];
|
|
dontUseCmakeBuildDir = true;
|
|
propagatedBuildInputs = [
|
|
xlink
|
|
bzip2
|
|
fp16
|
|
libnop
|
|
libarchive
|
|
xz
|
|
zlib
|
|
spdlog
|
|
nlohmann_json
|
|
opencv
|
|
python310Packages.python
|
|
python310Packages.pybind11
|
|
];
|
|
cmakeFlags = [
|
|
"-DHUNTER_ENABLED=OFF"
|
|
"-DBUILD_SHARED_LIBS=ON"
|
|
"-DDEPTHAI_ENABLE_BACKWARD=OFF"
|
|
"-DDEPTHAI_BINARIES_RESOURCE_COMPILE=ON"
|
|
"-DDEPTHAI_BOOTLOADER_FWP=${depthai-bootloader}"
|
|
"-DDEPTHAI_DEVICE_FWP=${depthai-device}"
|
|
];
|
|
patches = [
|
|
./patches/fix-cmake-build-env.patch
|
|
./patches/fw-in-nix-store.patch
|
|
# Source: https://github.com/luxonis/depthai-core/issues/447
|
|
./patches/no-hunter.patch
|
|
./patches/no-download.patch
|
|
];
|
|
postPatch = ''
|
|
# libnop has this set as an include dir for some reason. Make sure it exists.
|
|
# TODO: fix libnop eventually
|
|
mkdir include
|
|
|
|
# patch depthai to use bootloader and device fw located in the nix store
|
|
sed -i 's|"depthai-device-fwp-" DEPTHAI_DEVICE_VERSION ".tar.xz"|"${depthai-device}"|' depthai-core/src/utility/Resources.cpp
|
|
sed -i 's|"depthai-bootloader-fwp-" DEPTHAI_BOOTLOADER_VERSION ".tar.xz"|"${depthai-bootloader}"|' depthai-core/src/utility/Resources.cpp
|
|
'';
|
|
};
|
|
|
|
# blob converters make me sad :(
|
|
blobconverter-drv = { python310Packages }:
|
|
python310Packages.buildPythonPackage rec {
|
|
pname = "blobconverter";
|
|
version = "1.3.0";
|
|
doCheck = false;
|
|
propagatedBuildInputs = with python310Packages; [
|
|
requests pyyaml boto3
|
|
];
|
|
src = python310Packages.fetchPypi {
|
|
inherit pname version;
|
|
sha256 = "bxosxqTQNHpnXt3CF6oHUb1brAn9axkZW2QfbqnrHME=";
|
|
};
|
|
};
|
|
|
|
distinctipy-drv = { python310Packages }:
|
|
python310Packages.buildPythonPackage rec {
|
|
pname = "distinctipy";
|
|
version = "1.2.2";
|
|
propagatedBuildInputs = with python310Packages; [
|
|
numpy
|
|
];
|
|
src = python310Packages.fetchPypi {
|
|
inherit pname version;
|
|
sha256 = "gUWkInZqfmU1Sdi+wpeMC4Il+RptCL7ORiKMRKXslis=";
|
|
};
|
|
};
|
|
|
|
marshmallow-3-17-drv = {
|
|
lib,
|
|
fetchFromGitHub,
|
|
python310Packages,
|
|
}: python310Packages.buildPythonPackage rec {
|
|
pname = "marshmallow";
|
|
version = "3.17.0";
|
|
format = "setuptools";
|
|
|
|
src = fetchFromGitHub {
|
|
owner = "marshmallow-code";
|
|
repo = pname;
|
|
rev = version;
|
|
hash = "sha256-KfLC5fpZitHMcuTsMsm8K02cGGXxaMu0hdLeJUmc/Yg=";
|
|
};
|
|
|
|
propagatedBuildInputs = with python310Packages; [
|
|
packaging
|
|
];
|
|
|
|
checkInputs = with python310Packages; [
|
|
pytestCheckHook
|
|
pytz
|
|
simplejson
|
|
];
|
|
};
|
|
|
|
qt-py-drv = {
|
|
python310Packages,
|
|
}: python310Packages.buildPythonPackage rec {
|
|
pname = "qt-py";
|
|
version = "1.3.7";
|
|
doCheck = false;
|
|
propagatedBuildInputs = with python310Packages; [
|
|
pyside2
|
|
];
|
|
src = python310Packages.fetchPypi {
|
|
pname = "Qt.py";
|
|
inherit version;
|
|
sha256 = "gDx7301iMPmkZr4Z1Vk0oXPqu2FAbSHLkegMKj93Ox8=";
|
|
};
|
|
};
|
|
|
|
depthai-sdk-drv = {
|
|
python310Packages,
|
|
depthai-python,
|
|
distinctipy,
|
|
blobconverter,
|
|
marshmallow-3-17,
|
|
qt-py,
|
|
}: python310Packages.buildPythonPackage {
|
|
name = "depthai-sdk";
|
|
version = "1.9.0";
|
|
src = depthai-sdk;
|
|
sourceRoot = "source/depthai_sdk";
|
|
propagatedBuildInputs = with python310Packages; [
|
|
numpy
|
|
(opencv4.override { enableGtk2 = true; })
|
|
depthai-python
|
|
pyturbojpeg
|
|
marshmallow-3-17
|
|
blobconverter
|
|
distinctipy
|
|
xmltodict
|
|
pytube
|
|
matplotlib
|
|
qt-py
|
|
];
|
|
patches = [
|
|
./patches/no-opencv-contrib.patch
|
|
];
|
|
};
|
|
|
|
depthai-example-drv = {
|
|
python310Packages,
|
|
depthai-sdk,
|
|
depthai-python,
|
|
}: python310Packages.buildPythonApplication {
|
|
pname = "depthai-example";
|
|
src = self;
|
|
sourceRoot = "source/example";
|
|
version = "0.1";
|
|
propagatedBuildInputs = with python310Packages; [
|
|
depthai-sdk
|
|
];
|
|
preFixup = ''
|
|
# TODO: for some reason lookup of this shared lib doesn't just work
|
|
makeWrapperArgs+=("--prefix" "LD_LIBRARY_PATH" ":" "${depthai-python}/lib/python3.10/site-packages")
|
|
'';
|
|
};
|
|
|
|
in {
|
|
overlays.default = final: prev: {
|
|
xlink = final.callPackage xlink-drv {};
|
|
fp16 = final.callPackage fp16-drv {};
|
|
libnop = final.callPackage libnop-drv {};
|
|
depthai-python = final.callPackage depthai-python-drv {};
|
|
blobconverter = final.callPackage blobconverter-drv {};
|
|
distinctipy = final.callPackage distinctipy-drv {};
|
|
marshmallow-3-17 = final.callPackage marshmallow-3-17-drv {};
|
|
qt-py = final.callPackage qt-py-drv {};
|
|
depthai-sdk = final.callPackage depthai-sdk-drv {};
|
|
depthai-example = final.callPackage depthai-example-drv {};
|
|
};
|
|
|
|
packages = forAllSystems (system:
|
|
let
|
|
pkgs = import nixpkgs { inherit system; overlays = [ self.overlays.default ]; };
|
|
in rec {
|
|
default = depthai-sdk;
|
|
|
|
depthai-example = pkgs.depthai-example;
|
|
|
|
depthai-python = pkgs.depthai-python;
|
|
depthai-sdk = pkgs.depthai-sdk;
|
|
|
|
xlink = pkgs.xlink;
|
|
fp16 = pkgs.fp16;
|
|
libnop = pkgs.libnop;
|
|
blobconverter = pkgs.blobconverter;
|
|
distinctipy = pkgs.distinctipy;
|
|
marshmallow-3-17 = pkgs.marshmallow-3-17;
|
|
}
|
|
);
|
|
};
|
|
}
|