2021-07-27 14:14:53 +00:00
|
|
|
{ lib, stdenv, fetchurl, fetchpatch
|
2021-08-30 11:53:07 +00:00
|
|
|
, cmake, perl, go, python3
|
2022-11-02 20:24:32 +00:00
|
|
|
, protobuf, zlib, gtest, brotli, lz4, zstd, libusb1, pcre2
|
2021-05-30 20:06:45 +00:00
|
|
|
}:
|
|
|
|
|
2021-08-30 11:53:07 +00:00
|
|
|
let
|
|
|
|
pythonEnv = python3.withPackages(ps: [ ps.protobuf ]);
|
|
|
|
in
|
|
|
|
|
2021-05-30 20:06:45 +00:00
|
|
|
stdenv.mkDerivation rec {
|
|
|
|
pname = "android-tools";
|
2022-11-02 20:24:32 +00:00
|
|
|
version = "33.0.3";
|
2021-05-30 20:06:45 +00:00
|
|
|
|
|
|
|
src = fetchurl {
|
|
|
|
url = "https://github.com/nmeum/android-tools/releases/download/${version}/android-tools-${version}.tar.xz";
|
2022-11-02 20:24:32 +00:00
|
|
|
hash = "sha256-jOF02reB1d69Ke0PllciMfd3vuGbjvPBZ+M9PqdnC8U=";
|
2021-05-30 20:06:45 +00:00
|
|
|
};
|
|
|
|
|
2021-07-27 14:14:53 +00:00
|
|
|
patches = [
|
2022-10-15 14:38:28 +00:00
|
|
|
./android-tools-kernel-headers-6.0.diff
|
2021-07-27 14:14:53 +00:00
|
|
|
];
|
|
|
|
|
2022-10-28 05:09:56 +00:00
|
|
|
postPatch = lib.optionalString stdenv.isDarwin ''
|
|
|
|
sed -i 's/usb_linux/usb_osx/g' vendor/CMakeLists.{adb,fastboot}.txt
|
|
|
|
sed -i 's/libselinux libsepol/ /g;s#selinux/libselinux/include##g' vendor/CMakeLists.{fastboot,mke2fs}.txt
|
|
|
|
sed -z -i 's/add_library(libselinux.*selinux\/libsepol\/include)//g' vendor/CMakeLists.fastboot.txt
|
|
|
|
sed -i 's/e2fsdroid//g' vendor/CMakeLists.txt
|
|
|
|
sed -z -i 's/add_executable(e2fsdroid.*e2fsprogs\/misc)//g' vendor/CMakeLists.mke2fs.txt
|
|
|
|
'';
|
|
|
|
|
2021-05-30 20:06:45 +00:00
|
|
|
nativeBuildInputs = [ cmake perl go ];
|
2022-11-02 20:24:32 +00:00
|
|
|
buildInputs = [ protobuf zlib gtest brotli lz4 zstd libusb1 pcre2 ];
|
2021-08-30 11:53:07 +00:00
|
|
|
propagatedBuildInputs = [ pythonEnv ];
|
2021-05-30 20:06:45 +00:00
|
|
|
|
|
|
|
# Don't try to fetch any Go modules via the network:
|
|
|
|
GOFLAGS = [ "-mod=vendor" ];
|
|
|
|
|
2022-10-28 05:09:56 +00:00
|
|
|
NIX_CFLAGS_COMPILE = lib.optionals stdenv.isDarwin [
|
|
|
|
"-D_DARWIN_C_SOURCE"
|
|
|
|
];
|
|
|
|
|
|
|
|
NIX_LDFLAGS = lib.optionals stdenv.isDarwin [
|
|
|
|
"-framework CoreFoundation"
|
|
|
|
"-framework IOKit"
|
|
|
|
];
|
|
|
|
|
2021-05-30 20:06:45 +00:00
|
|
|
preConfigure = ''
|
|
|
|
export GOCACHE=$TMPDIR/go-cache
|
|
|
|
'';
|
|
|
|
|
2021-08-30 11:53:07 +00:00
|
|
|
postInstall = ''
|
|
|
|
install -Dm755 ../vendor/avb/avbtool.py -t $out/bin
|
|
|
|
'';
|
|
|
|
|
2021-05-30 20:06:45 +00:00
|
|
|
meta = with lib; {
|
|
|
|
description = "Android SDK platform tools";
|
|
|
|
longDescription = ''
|
|
|
|
Android SDK Platform-Tools is a component for the Android SDK. It
|
|
|
|
includes tools that interface with the Android platform, such as adb and
|
|
|
|
fastboot. These tools are required for Android app development. They're
|
|
|
|
also needed if you want to unlock your device bootloader and flash it
|
|
|
|
with a new system image.
|
|
|
|
Currently the following tools are supported:
|
|
|
|
- adb
|
|
|
|
- fastboot
|
|
|
|
- mke2fs.android (required by fastboot)
|
|
|
|
- simg2img, img2simg, append2simg
|
2022-01-06 14:59:31 +00:00
|
|
|
- lpdump, lpmake, lpadd, lpflash, lpunpack
|
|
|
|
- mkbootimg, unpack_bootimg, repack_bootimg
|
2021-05-30 20:06:45 +00:00
|
|
|
'';
|
|
|
|
# https://developer.android.com/studio/command-line#tools-platform
|
|
|
|
# https://developer.android.com/studio/releases/platform-tools
|
|
|
|
homepage = "https://github.com/nmeum/android-tools";
|
|
|
|
license = with licenses; [ asl20 unicode-dfs-2015 ];
|
2022-10-28 05:09:56 +00:00
|
|
|
platforms = platforms.unix;
|
2021-05-30 20:06:45 +00:00
|
|
|
maintainers = with maintainers; [ primeos ];
|
|
|
|
};
|
|
|
|
}
|