1{deployAndroidPackage, lib, package, autoPatchelfHook, makeWrapper, os, pkgs, pkgsi686Linux, postInstall}:
2
3deployAndroidPackage {
4 name = "androidsdk";
5 inherit os package;
6 nativeBuildInputs = [ makeWrapper ]
7 ++ lib.optionals (os == "linux") [ autoPatchelfHook ];
8 buildInputs = lib.optional (os == "linux") (
9 (with pkgs; [ glibc freetype fontconfig fontconfig.lib
10 stdenv.cc.cc.libgcc or null # fix for https://github.com/NixOS/nixpkgs/issues/226357
11 ])
12 ++ (with pkgs.xorg; [ libX11 libXrender libXext ])
13 ++ (with pkgsi686Linux; [ glibc xorg.libX11 xorg.libXrender xorg.libXext fontconfig.lib freetype zlib ])
14 );
15
16 patchInstructions = ''
17 ${lib.optionalString (os == "linux") ''
18 # Auto patch all binaries
19 autoPatchelf .
20 ''}
21
22 # Wrap all scripts that require JAVA_HOME
23 for i in bin; do
24 find $i -maxdepth 1 -type f -executable | while read program; do
25 if grep -q "JAVA_HOME" $program; then
26 wrapProgram $PWD/$program --prefix PATH : ${pkgs.jdk8}/bin
27 fi
28 done
29 done
30
31 # Wrap monitor script
32 wrapProgram $PWD/monitor \
33 --prefix PATH : ${pkgs.jdk8}/bin \
34 --prefix LD_LIBRARY_PATH : ${lib.makeLibraryPath (with pkgs; [ xorg.libX11 xorg.libXtst ])}
35
36 # Patch all script shebangs
37 patchShebangs .
38
39 cd $out/libexec/android-sdk
40 ${postInstall}
41 '';
42
43 meta.license = lib.licenses.unfree;
44}