1{
2 stdenv,
3 lib,
4 fetchFromGitHub,
5 fetchpatch2,
6 kernel,
7 kernelModuleMakeFlags,
8}:
9
10stdenv.mkDerivation {
11 pname = "gasket";
12 version = "1.0-18-unstable-2024-04-25";
13
14 src = fetchFromGitHub {
15 owner = "google";
16 repo = "gasket-driver";
17 rev = "5815ee3908a46a415aac616ac7b9aedcb98a504c";
18 sha256 = "O17+msok1fY5tdX1DvqYVw6plkUDF25i8sqwd6mxYf8=";
19 };
20
21 patches = [
22 (fetchpatch2 {
23 # https://github.com/google/gasket-driver/issues/36
24 # https://github.com/google/gasket-driver/pull/35
25 name = "linux-6.12-compat.patch";
26 url = "https://github.com/google/gasket-driver/commit/4b2a1464f3b619daaf0f6c664c954a42c4b7ce00.patch";
27 hash = "sha256-UOoOSEnpUMa4QXWVFpGFxBoF5szXaLEfcWtfKatO5XY=";
28 })
29 (fetchpatch2 {
30 # https://github.com/google/gasket-driver/issues/39
31 # https://github.com/google/gasket-driver/pull/40
32 name = "linux-6.13-compat.patch";
33 url = "https://github.com/google/gasket-driver/commit/6fbf8f8f8bcbc0ac9c9bef7a56f495a2c9872652.patch";
34 hash = "sha256-roCo0/ETWuDVtZfbpFbrmy/icNI12A/ozOGQNLTtBUs=";
35 })
36 ];
37
38 postPatch = ''
39 cd src
40 '';
41
42 makeFlags = kernelModuleMakeFlags ++ [
43 "-C"
44 "${kernel.dev}/lib/modules/${kernel.modDirVersion}/build"
45 "M=$(PWD)"
46 ];
47 buildFlags = [ "modules" ];
48
49 installFlags = [ "INSTALL_MOD_PATH=${placeholder "out"}" ];
50 installTargets = [ "modules_install" ];
51
52 hardeningDisable = [
53 "pic"
54 "format"
55 ];
56 nativeBuildInputs = kernel.moduleBuildDependencies;
57
58 meta = with lib; {
59 description = "Coral Gasket Driver allows usage of the Coral EdgeTPU on Linux systems";
60 homepage = "https://github.com/google/gasket-driver";
61 license = licenses.gpl2Only;
62 maintainers = [ lib.maintainers.kylehendricks ];
63 platforms = platforms.linux;
64 broken = versionOlder kernel.version "5.15";
65 };
66}