base16-schemes: unstable-2024-06-21 -> unstable-2024-11-12
[NixPkgs.git] / pkgs / by-name / li / libedgetpu / package.nix
blob9ead9c5f60b33cd9e8e70a25de5c895b4eb96d20
2   lib,
3   stdenv,
4   fetchFromGitHub,
5   libusb1,
6   abseil-cpp,
7   flatbuffers,
8   fetchpatch,
9   xxd,
11 let
12   # Tensorflow 2.16.1 requires Flatbuffers 23.5.26
13   # Compile as a shared library
14   flatbuffers_23_5_26 = flatbuffers.overrideAttrs (oldAttrs: rec {
15     version = "23.5.26";
16     cmakeFlags = (oldAttrs.cmakeFlags or [ ]) ++ [ "-DFLATBUFFERS_BUILD_SHAREDLIB=ON" ];
17     NIX_CXXSTDLIB_COMPILE = "-std=c++17";
18     configureFlags = (oldAttrs.configureFlags or [ ]) ++ [ "--enable-shared" ];
19     src = fetchFromGitHub {
20       owner = "google";
21       repo = "flatbuffers";
22       rev = "v${version}";
23       hash = "sha256-e+dNPNbCHYDXUS/W+hMqf/37fhVgEGzId6rhP3cToTE=";
24     };
25   });
27 stdenv.mkDerivation {
28   pname = "libedgetpu";
29   version = "0-unstable-2024-03-14";
31   src = fetchFromGitHub {
32     owner = "google-coral";
33     repo = "libedgetpu";
34     rev = "e35aed18fea2e2d25d98352e5a5bd357c170bd4d";
35     hash = "sha256-SabiFG/EgspiCFpg8XQs6RjFhrPPUfhILPmYQQA1E2w=";
36   };
38   patches = [
39     (fetchpatch {
40       name = "fix-makefile-to-compile-with-latest-tensorflow.patch";
41       url = "https://patch-diff.githubusercontent.com/raw/google-coral/libedgetpu/pull/66.patch";
42       hash = "sha256-mMODpQmikfXtsQvtgh26cy97EiykYNLngSjidOBt/3I=";
43     })
44   ];
46   makeFlags = [
47     "-f"
48     "makefile_build/Makefile"
49     "libedgetpu"
50   ];
52   buildInputs = [
53     abseil-cpp
54     libusb1
55     flatbuffers_23_5_26
56   ];
58   nativeBuildInputs = [ xxd ];
60   NIX_CXXSTDLIB_COMPILE = "-std=c++17";
62   TFROOT = fetchFromGitHub {
63     owner = "tensorflow";
64     repo = "tensorflow";
65     rev = "v2.16.1";
66     hash = "sha256-UPvK5Kc/FNVJq3FchN5IIBBObvcHtAPVv0ARzWzA35M=";
67   };
69   enableParallelBuilding = true;
71   installPhase = ''
72     runHook preInstall
73     install -Dm555 out/direct/k8/libedgetpu.so.1.0 -t $out/lib
74     ln -s $out/lib/libedgetpu.so.1.0 $out/lib/libedgetpu.so.1
75     install -Dm444 debian/edgetpu-accelerator.rules $out/lib/udev/rules.d/99-edgetpu-accelerator.rules
76     install -Dm444 tflite/public/*.h -t $out/include
77     runHook postInstall
78   '';
80   meta = {
81     homepage = "https://github.com/google-coral/libedgetpu";
82     description = "Userspace level runtime driver for Coral devices";
83     license = lib.licenses.asl20;
84     maintainers = with lib.maintainers; [ frenetic00 ];
85     platforms = lib.platforms.linux;
86   };