Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{ stdenv, lib, pkgs, pkgsHostHost, makeWrapper, autoPatchelfHook 2, deployAndroidPackage, package, os, platform-tools 3}: 4 5let 6 runtime_paths = lib.makeBinPath (with pkgsHostHost; [ 7 coreutils file findutils gawk gnugrep gnused jdk python3 which 8 ]) + ":${platform-tools}/platform-tools"; 9in 10deployAndroidPackage rec { 11 inherit package os; 12 nativeBuildInputs = [ makeWrapper ] 13 ++ lib.optionals stdenv.isLinux [ autoPatchelfHook ]; 14 autoPatchelfIgnoreMissingDeps = true; 15 buildInputs = lib.optionals (os == "linux") [ pkgs.zlib ]; 16 17 patchElfBnaries = '' 18 # Patch the executables of the toolchains, but not the libraries -- they are needed for crosscompiling 19 if [ -d $out/libexec/android-sdk/ndk-bundle/toolchains/renderscript/prebuilt/linux-x86_64/lib64 ]; then 20 addAutoPatchelfSearchPath $out/libexec/android-sdk/ndk-bundle/toolchains/renderscript/prebuilt/linux-x86_64/lib64 21 fi 22 23 if [ -d $out/libexec/android-sdk/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/lib64 ]; then 24 addAutoPatchelfSearchPath $out/libexec/android-sdk/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/lib64 25 fi 26 27 find toolchains -type d -name bin -or -name lib64 | while read dir; do 28 autoPatchelf "$dir" 29 done 30 31 # Patch executables 32 if [ -d prebuilt/linux-x86_64 ]; then 33 autoPatchelf prebuilt/linux-x86_64 34 fi 35 ''; 36 37 patchOsAgnostic = '' 38 patchShebangs . 39 40 # TODO: allow this stuff 41 rm -rf docs tests 42 43 # Ndk now has a prebuilt toolchains inside, the file layout has changed, we do a symlink 44 # to still support the old standalone toolchains builds. 45 if [ -d $out/libexec/android-sdk/ndk ] && [ ! -d $out/libexec/android-sdk/ndk-bundle ]; then 46 ln -sf $out/libexec/android-sdk/ndk/${package.revision} $out/libexec/android-sdk/ndk-bundle 47 elif [ ! -d $out/libexec/android-sdk/ndk-bundle ]; then 48 echo "The ndk-bundle layout has changed. The nix expressions have to be updated!" 49 exit 1 50 fi 51 52 # fix ineffective PROGDIR / MYNDKDIR determination 53 for progname in ndk-build; do 54 sed -i -e 's|^PROGDIR=`dirname $0`|PROGDIR=`dirname $(readlink -f $(which $0))`|' $progname 55 done 56 57 # wrap 58 for progname in ndk-build; do 59 wrapProgram "$(pwd)/$progname" --prefix PATH : "${runtime_paths}" 60 done 61 62 # make some executables available in PATH 63 mkdir -p $out/bin 64 for progname in ndk-build; do 65 ln -sf ../libexec/android-sdk/ndk-bundle/$progname $out/bin/$progname 66 done 67 ''; 68 69 patchInstructions = patchOsAgnostic 70 + lib.optionalString stdenv.isLinux patchElfBnaries; 71 72 noAuditTmpdir = true; # Audit script gets invoked by the build/ component in the path for the make standalone script 73}