1 { lib, stdenv, fetchurl, fetchpatch
2 , cmake, perl, go, python3
3 , protobuf, zlib, gtest, brotli, lz4, zstd, libusb1, pcre2
7 pythonEnv = python3.withPackages(ps: [ ps.protobuf ]);
10 stdenv.mkDerivation rec {
11 pname = "android-tools";
15 url = "https://github.com/nmeum/android-tools/releases/download/${version}/android-tools-${version}.tar.xz";
16 hash = "sha256-jOF02reB1d69Ke0PllciMfd3vuGbjvPBZ+M9PqdnC8U=";
20 ./android-tools-kernel-headers-6.0.diff
23 postPatch = lib.optionalString stdenv.isDarwin ''
24 sed -i 's/usb_linux/usb_osx/g' vendor/CMakeLists.{adb,fastboot}.txt
25 sed -i 's/libselinux libsepol/ /g;s#selinux/libselinux/include##g' vendor/CMakeLists.{fastboot,mke2fs}.txt
26 sed -z -i 's/add_library(libselinux.*selinux\/libsepol\/include)//g' vendor/CMakeLists.fastboot.txt
27 sed -i 's/e2fsdroid//g' vendor/CMakeLists.txt
28 sed -z -i 's/add_executable(e2fsdroid.*e2fsprogs\/misc)//g' vendor/CMakeLists.mke2fs.txt
31 nativeBuildInputs = [ cmake perl go ];
32 buildInputs = [ protobuf zlib gtest brotli lz4 zstd libusb1 pcre2 ];
33 propagatedBuildInputs = [ pythonEnv ];
35 # Don't try to fetch any Go modules via the network:
36 GOFLAGS = [ "-mod=vendor" ];
38 NIX_CFLAGS_COMPILE = lib.optionals stdenv.isDarwin [
42 NIX_LDFLAGS = lib.optionals stdenv.isDarwin [
43 "-framework CoreFoundation"
48 export GOCACHE=$TMPDIR/go-cache
52 install -Dm755 ../vendor/avb/avbtool.py -t $out/bin
56 description = "Android SDK platform tools";
58 Android SDK Platform-Tools is a component for the Android SDK. It
59 includes tools that interface with the Android platform, such as adb and
60 fastboot. These tools are required for Android app development. They're
61 also needed if you want to unlock your device bootloader and flash it
62 with a new system image.
63 Currently the following tools are supported:
66 - mke2fs.android (required by fastboot)
67 - simg2img, img2simg, append2simg
68 - lpdump, lpmake, lpadd, lpflash, lpunpack
69 - mkbootimg, unpack_bootimg, repack_bootimg
71 # https://developer.android.com/studio/command-line#tools-platform
72 # https://developer.android.com/studio/releases/platform-tools
73 homepage = "https://github.com/nmeum/android-tools";
74 license = with licenses; [ asl20 unicode-dfs-2015 ];
75 platforms = platforms.unix;
76 maintainers = with maintainers; [ primeos ];