1{ lib, stdenv, fetchurl, fetchpatch
2, cmake, pkg-config, perl, go, python3
3, protobuf, zlib, gtest, brotli, lz4, zstd, libusb1, pcre2
4}:
5
6let
7 pythonEnv = python3.withPackages(ps: [ ps.protobuf ]);
8in
9
10stdenv.mkDerivation rec {
11 pname = "android-tools";
12 version = "33.0.3p1";
13
14 src = fetchurl {
15 url = "https://github.com/nmeum/android-tools/releases/download/${version}/android-tools-${version}.tar.xz";
16 hash = "sha256-viBHzyVgUWdK9a60u/7SdpiVEvgNEZHihkyRkGH5Ydg=";
17 };
18
19 patches = [
20 (fetchpatch {
21 name = "add-macos-platform.patch";
22 url = "https://github.com/nmeum/android-tools/commit/a1ab35b31525966e0f0770047cd82accb36d025b.patch";
23 hash = "sha256-6O3ekDf0qPdzcfINFF8Ae4XOYgnQWTBhvu9SCFSHkXY=";
24 })
25 ];
26
27 nativeBuildInputs = [ cmake pkg-config perl go ];
28 buildInputs = [ protobuf zlib gtest brotli lz4 zstd libusb1 pcre2 ];
29 propagatedBuildInputs = [ pythonEnv ];
30
31 # Don't try to fetch any Go modules via the network:
32 GOFLAGS = [ "-mod=vendor" ];
33
34 preConfigure = ''
35 export GOCACHE=$TMPDIR/go-cache
36 '';
37
38 postInstall = ''
39 install -Dm755 ../vendor/avb/avbtool.py -t $out/bin
40 '';
41
42 meta = with lib; {
43 description = "Android SDK platform tools";
44 longDescription = ''
45 Android SDK Platform-Tools is a component for the Android SDK. It
46 includes tools that interface with the Android platform, such as adb and
47 fastboot. These tools are required for Android app development. They're
48 also needed if you want to unlock your device bootloader and flash it
49 with a new system image.
50 Currently the following tools are supported:
51 - adb
52 - fastboot
53 - mke2fs.android (required by fastboot)
54 - simg2img, img2simg, append2simg
55 - lpdump, lpmake, lpadd, lpflash, lpunpack
56 - mkbootimg, unpack_bootimg, repack_bootimg
57 '';
58 # https://developer.android.com/studio/command-line#tools-platform
59 # https://developer.android.com/studio/releases/platform-tools
60 homepage = "https://github.com/nmeum/android-tools";
61 license = with licenses; [ asl20 unicode-dfs-2015 ];
62 platforms = platforms.unix;
63 maintainers = with maintainers; [ primeos ];
64 };
65}