From 4d1448189c9d227625e7043dafabdaa81031aea3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Numbus?= Date: Tue, 3 Mar 2026 14:23:53 +0100 Subject: [PATCH] Added coral TPU driver compile files. Try to fix passbolt YAML error. --- modules/hardware/pcie-coral/coral.nix | 12 +++++ modules/hardware/pcie-coral/gasket.nix | 35 +++++++++++++ modules/hardware/pcie-coral/libedgetpu.nix | 59 ++++++++++++++++++++++ modules/services/passbolt.nix | 2 +- 4 files changed, 107 insertions(+), 1 deletion(-) create mode 100644 modules/hardware/pcie-coral/coral.nix create mode 100644 modules/hardware/pcie-coral/gasket.nix create mode 100644 modules/hardware/pcie-coral/libedgetpu.nix diff --git a/modules/hardware/pcie-coral/coral.nix b/modules/hardware/pcie-coral/coral.nix new file mode 100644 index 0000000..c98c359 --- /dev/null +++ b/modules/hardware/pcie-coral/coral.nix @@ -0,0 +1,12 @@ +{ config, pkgs, ... }: + +let + libedgetpu = pkgs.callPackage ./libedgetpu.nix {}; + gasket = config.boot.kernelPackages.callPackage ./gasket.nix {}; +in + +{ + services.udev.packages = [ libedgetpu ]; + users.groups.plugdev = {}; + boot.extraModulePackages = [ gasket ]; +} \ No newline at end of file diff --git a/modules/hardware/pcie-coral/gasket.nix b/modules/hardware/pcie-coral/gasket.nix new file mode 100644 index 0000000..e2af4d5 --- /dev/null +++ b/modules/hardware/pcie-coral/gasket.nix @@ -0,0 +1,35 @@ +{ stdenv, lib, fetchFromGitHub, kernel }: + +stdenv.mkDerivation rec { + pname = "gasket"; + version = "1.0-18"; + + src = fetchFromGitHub { + owner = "google"; + repo = "gasket-driver"; + rev = "97aeba584efd18983850c36dcf7384b0185284b3"; + sha256 = "pJwrrI7jVKFts4+bl2xmPIAD01VKFta2SRuElerQnTo="; + }; + + makeFlags = [ + "-C" + "${kernel.dev}/lib/modules/${kernel.modDirVersion}/build" + "M=$(PWD)" + ]; + buildFlags = [ "modules" ]; + + installFlags = [ "INSTALL_MOD_PATH=${placeholder "out"}" ]; + installTargets = [ "modules_install" ]; + + sourceRoot = "source/src"; + hardeningDisable = [ "pic" "format" ]; + nativeBuildInputs = kernel.moduleBuildDependencies; + + meta = with lib; { + description = "The Coral Gasket Driver allows usage of the Coral EdgeTPU on Linux systems."; + homepage = "https://github.com/google/gasket-driver"; + license = licenses.gpl2; + maintainers = [ lib.maintainers.kylehendricks ]; + platforms = platforms.linux; + }; +} \ No newline at end of file diff --git a/modules/hardware/pcie-coral/libedgetpu.nix b/modules/hardware/pcie-coral/libedgetpu.nix new file mode 100644 index 0000000..daa42dd --- /dev/null +++ b/modules/hardware/pcie-coral/libedgetpu.nix @@ -0,0 +1,59 @@ +{ stdenv, lib, fetchFromGitHub, libusb1, abseil-cpp, flatbuffers, xxd }: + +let + flatbuffers_1_12 = flatbuffers.overrideAttrs (oldAttrs: rec { + version = "1.12.0"; + NIX_CFLAGS_COMPILE = "-Wno-error=class-memaccess -Wno-error=maybe-uninitialized"; + cmakeFlags = (oldAttrs.cmakeFlags or []) ++ ["-DFLATBUFFERS_BUILD_SHAREDLIB=ON"]; + NIX_CXXSTDLIB_COMPILE = "-std=c++17"; + configureFlags = (oldAttrs.configureFlags or []) ++ ["--enable-shared"]; + src = fetchFromGitHub { + owner = "google"; + repo = "flatbuffers"; + rev = "v${version}"; + sha256 = "sha256-L1B5Y/c897Jg9fGwT2J3+vaXsZ+lfXnskp8Gto1p/Tg="; + }; + }); + +in stdenv.mkDerivation rec { + pname = "libedgetpu"; + version = "grouper"; + + src = fetchFromGitHub { + owner = "google-coral"; + repo = pname; + rev = "release-${version}"; + sha256 = "sha256-73hwItimf88Iqnb40lk4ul/PzmCNIfdt6Afi+xjNiBE="; + }; + + makeFlags = ["-f" "makefile_build/Makefile" "libedgetpu" ]; + + buildInputs = [ + libusb1 + abseil-cpp + flatbuffers_1_12 + ]; + + nativeBuildInputs = [ + xxd + ]; + + NIX_CXXSTDLIB_COMPILE = "-std=c++17"; + + TFROOT = "${fetchFromGitHub { + owner = "tensorflow"; + repo = "tensorflow"; + rev = "v2.7.4"; + sha256 = "sha256-liDbUAdaVllB0b74aBeqNxkYNu/zPy7k3CevzRF5dk0="; + }}"; + + enableParallelBuilding = false; + + installPhase = '' + mkdir -p $out/lib + cp out/direct/k8/libedgetpu.so.1.0 $out/lib + ln -s $out/lib/libedgetpu.so.1.0 $out/lib/libedgetpu.so.1 + mkdir -p $out/lib/udev/rules.d + cp debian/edgetpu-accelerator.rules $out/lib/udev/rules.d/99-edgetpu-accelerator.rules + ''; +} \ No newline at end of file diff --git a/modules/services/passbolt.nix b/modules/services/passbolt.nix index 16879d9..2e642bc 100644 --- a/modules/services/passbolt.nix +++ b/modules/services/passbolt.nix @@ -69,7 +69,7 @@ helper.mkPodmanService { "0", "passbolt-database:3306", "--", - "/docker-entrypoint.sh", + "/docker-entrypoint.sh" ] depends_on: - passbolt-database