Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at 16.09 85 lines 2.5 kB view raw
1{ stdenv, fetchurl, zlib, ncurses, p7zip, lib, makeWrapper 2, coreutils, file, findutils, gawk, gnugrep, gnused, jdk, which 3, platformTools 4}: 5 6assert stdenv.isLinux; 7 8stdenv.mkDerivation rec { 9 name = "android-ndk-r10e"; 10 11 src = if stdenv.system == "i686-linux" 12 then fetchurl { 13 url = "http://dl.google.com/android/ndk/${name}-linux-x86.bin"; 14 sha256 = "1xbxra5v3bm6cmxyx8yyya5r93jh5m064aibgwd396xdm8jpvc4j"; 15 } 16 else if stdenv.system == "x86_64-linux" then fetchurl { 17 url = "http://dl.google.com/android/ndk/${name}-linux-x86_64.bin"; 18 sha256 = "0nhxixd0mq4ib176ya0hclnlbmhm8f2lab6i611kiwbzyqinfb8h"; 19 } 20 else throw "platform ${stdenv.system} not supported!"; 21 22 phases = "buildPhase"; 23 24 buildInputs = [ p7zip makeWrapper ]; 25 26 buildCommand = let 27 bin_path = "$out/bin"; 28 pkg_path = "$out/libexec/${name}"; 29 sed_script_1 = 30 "'s|^PROGDIR=`dirname $0`" + 31 "|PROGDIR=`dirname $(readlink -f $(which $0))`|'"; 32 sed_script_2 = 33 "'s|^MYNDKDIR=`dirname $0`" + 34 "|MYNDKDIR=`dirname $(readlink -f $(which $0))`|'"; 35 runtime_paths = (lib.makeBinPath [ 36 coreutils file findutils 37 gawk gnugrep gnused 38 jdk 39 which 40 ]) + ":${platformTools}/platform-tools"; 41 in '' 42 set -x 43 mkdir -pv $out/libexec 44 cd $out/libexec 45 7z x $src 46 47 # so that it doesn't fail because of read-only permissions set 48 cd - 49 patch -p1 \ 50 --no-backup-if-mismatch \ 51 -d $out/libexec/${name} < ${ ./make-standalone-toolchain.patch } 52 cd ${pkg_path} 53 54 find $out \( \ 55 \( -type f -a -name "*.so*" \) -o \ 56 \( -type f -a -perm -0100 \) \ 57 \) -exec patchelf --set-interpreter ${stdenv.cc.libc.out}/lib/ld-*so.? \ 58 --set-rpath ${stdenv.lib.makeLibraryPath [ zlib.out ncurses ]} {} \; 59 # fix ineffective PROGDIR / MYNDKDIR determination 60 for i in ndk-build ndk-gdb ndk-gdb-py 61 do 62 sed -i -e ${sed_script_1} $i 63 done 64 sed -i -e ${sed_script_2} ndk-which 65 # a bash script 66 patchShebangs ndk-which 67 # make some executables available in PATH 68 mkdir -pv ${bin_path} 69 for i in \ 70 ndk-build ndk-depends ndk-gdb ndk-gdb-py ndk-gdb.py ndk-stack ndk-which 71 do 72 ln -sf ${pkg_path}/$i ${bin_path}/$i 73 done 74 # wrap 75 for i in ndk-build ndk-gdb ndk-gdb-py ndk-which 76 do 77 wrapProgram "${bin_path}/$i" --prefix PATH : "${runtime_paths}" 78 done 79 ''; 80 81 meta = { 82 platforms = stdenv.lib.platforms.linux; 83 hydraPlatforms = []; 84 }; 85}