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