1{
2 lib,
3 stdenv,
4 fetchurl,
5 cmake,
6 ninja,
7 pkg-config,
8 perl,
9 go,
10 python3,
11 protobuf,
12 zlib,
13 gtest,
14 brotli,
15 lz4,
16 zstd,
17 pcre2,
18 fetchpatch2,
19 fmt,
20 udev,
21}:
22
23let
24 pythonEnv = python3.withPackages (ps: [ ps.protobuf ]);
25in
26
27stdenv.mkDerivation rec {
28 pname = "android-tools";
29 version = "35.0.2";
30
31 src = fetchurl {
32 url = "https://github.com/nmeum/android-tools/releases/download/${version}/android-tools-${version}.tar.xz";
33 hash = "sha256-0sMiIoAxXzbYv6XALXYytH42W/4ud+maNWT7ZXbwQJc=";
34 };
35
36 patches = [
37 (fetchpatch2 {
38 url = "https://raw.githubusercontent.com/nmeum/android-tools/0c4d79943e23785589ce1881cbb5a9bc76d64d9b/patches/extras/0003-extras-libjsonpb-Fix-incompatibility-with-protobuf-v.patch";
39 stripLen = 1;
40 extraPrefix = "vendor/extras/";
41 hash = "sha256-PO6ZKP54ri2ujVa/uFXgMy/zMQjjIo4e/EPW2Cu6a1Q=";
42 })
43 ];
44
45 nativeBuildInputs = [
46 cmake
47 ninja
48 pkg-config
49 perl
50 go
51 ];
52 buildInputs = [
53 protobuf
54 zlib
55 gtest
56 brotli
57 lz4
58 zstd
59 pcre2
60 fmt
61 ]
62 ++ lib.optionals stdenv.hostPlatform.isLinux [ udev ];
63 propagatedBuildInputs = [ pythonEnv ];
64
65 preConfigure = ''
66 export GOCACHE=$TMPDIR/go-cache
67 '';
68
69 cmakeFlags = [
70 (lib.cmakeBool "CMAKE_FIND_PACKAGE_PREFER_CONFIG" true)
71 (lib.cmakeBool "protobuf_MODULE_COMPATIBLE" true)
72 (lib.cmakeBool "ANDROID_TOOLS_LIBUSB_ENABLE_UDEV" stdenv.hostPlatform.isLinux)
73 (lib.cmakeBool "ANDROID_TOOLS_USE_BUNDLED_LIBUSB" true)
74 ];
75
76 meta = {
77 description = "Android SDK platform tools";
78 longDescription = ''
79 Android SDK Platform-Tools is a component for the Android SDK. It
80 includes tools that interface with the Android platform, such as adb and
81 fastboot. These tools are required for Android app development. They're
82 also needed if you want to unlock your device bootloader and flash it
83 with a new system image.
84 Currently the following tools are supported:
85 - adb
86 - fastboot
87 - mke2fs.android (required by fastboot)
88 - simg2img, img2simg, append2simg
89 - lpdump, lpmake, lpadd, lpflash, lpunpack
90 - mkbootimg, unpack_bootimg, repack_bootimg, avbtool
91 - mkdtboimg
92 '';
93 # https://developer.android.com/studio/command-line#tools-platform
94 # https://developer.android.com/studio/releases/platform-tools
95 homepage = "https://github.com/nmeum/android-tools";
96 license = with lib.licenses; [
97 asl20
98 unicode-dfs-2015
99 mit
100 ];
101 platforms = lib.platforms.unix;
102 teams = [ lib.teams.android ];
103 };
104}