summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--pkgs/tools/misc/android-tools/default.nix17
1 files changed, 16 insertions, 1 deletions
diff --git a/pkgs/tools/misc/android-tools/default.nix b/pkgs/tools/misc/android-tools/default.nix
index b18366b057f..8d74e74cb8a 100644
--- a/pkgs/tools/misc/android-tools/default.nix
+++ b/pkgs/tools/misc/android-tools/default.nix
@@ -1,8 +1,12 @@
 { lib, stdenv, fetchurl, fetchpatch
-, cmake, perl, go
+, cmake, perl, go, python3
 , protobuf, zlib, gtest, brotli, lz4, zstd, libusb1, pcre2, fmt_7
 }:
 
+let
+  pythonEnv = python3.withPackages(ps: [ ps.protobuf ]);
+in
+
 stdenv.mkDerivation rec {
   pname = "android-tools";
   version = "31.0.2";
@@ -23,8 +27,13 @@ stdenv.mkDerivation rec {
     })
   ];
 
+  postPatch = ''
+    sed -i -E "0,/import api_pb2/ s//from google.protobuf import api_pb2/" vendor/avb/aftltool.py
+  '';
+
   nativeBuildInputs = [ cmake perl go ];
   buildInputs = [ protobuf zlib gtest brotli lz4 zstd libusb1 pcre2 fmt_7 ];
+  propagatedBuildInputs = [ pythonEnv ];
 
   # Don't try to fetch any Go modules via the network:
   GOFLAGS = [ "-mod=vendor" ];
@@ -33,6 +42,12 @@ stdenv.mkDerivation rec {
     export GOCACHE=$TMPDIR/go-cache
   '';
 
+  postInstall = ''
+    install -Dm755 ../vendor/avb/aftltool.py -t $out/bin
+    install -Dm755 ../vendor/avb/avbtool.py -t $out/bin
+    install -Dm755 ../vendor/mkbootimg/mkbootimg.py $out/bin/mkbootimg
+  '';
+
   meta = with lib; {
     description = "Android SDK platform tools";
     longDescription = ''