@@ -41,10 +41,16 @@ stdenv.mkDerivation rec {
4141 }
4242 else throw "platform not ${stdenv.hostPlatform.system} supported!";
4343
44+ emulator = fetchurl {
45+ url = "https://dl.google.com/android/repository/emulator-linux-4969155.zip";
46+ sha256 = "0iw0j6j3w9zpfalsa7xq2czz4vzgq96zk2zddjhanwwx4p8fhrfd";
47+ };
48+
4449 buildCommand = ''
4550 mkdir -p $out/libexec
4651 cd $out/libexec
4752 unpackFile $src
53+ unpackFile $emulator
4854 cd tools
4955
5056 for f in monitor bin/monkeyrunner bin/uiautomatorviewer
@@ -76,13 +82,16 @@ stdenv.mkDerivation rec {
7682 # The emulators need additional libraries, which are dynamically loaded => let's wrap them
7783
7884 ${stdenv.lib.optionalString (stdenv.hostPlatform.system == "x86_64-linux") ''
79− for i in emulator emulator-check
85+ cd ..
86+ for i in emulator/emulator* emulator/qemu/linux-x86_64/qemu-system-*
8087 do
88+ patchelf --set-interpreter ${stdenv.cc.libc.out}/lib/ld-linux-x86-64.so.2 $i
8189 wrapProgram `pwd`/$i \
8290 --prefix PATH : ${stdenv.lib.makeBinPath [ file glxinfo ]} \
8391 --suffix LD_LIBRARY_PATH : `pwd`/lib:${makeLibraryPath [ stdenv.cc.cc libX11 libxcb libXau libXdmcp libXext libGLU_combined alsaLib zlib libpulseaudio dbus.lib ]} \
8492 --suffix QT_XKB_CONFIG_ROOT : ${xkeyboardconfig}/share/X11/xkb
8593 done
94+ cd tools
8695 ''}
8796 ''}
8897
@@ -93,7 +102,7 @@ stdenv.mkDerivation rec {
93102 # The monitor requires some more patching
94103
95104 cd lib/monitor-x86
96− patchelf --set-interpreter ${stdenv.cc.libc.out}/lib/ld-linux.so.2 monitor
105+ patchelf --set-interpreter ${stdenv_32bit.cc.libc.out}/lib/ld-linux.so.2 monitor
97106 patchelf --set-rpath ${makeLibraryPath [ libX11 libXext libXrender freetype fontconfig ]} libcairo-swt.so
98107
99108 wrapProgram `pwd`/monitor \
@@ -263,6 +272,14 @@ stdenv.mkDerivation rec {
263272 fi
264273 done
265274
275+ for i in $out/libexec/emulator/*
276+ do
277+ if [ ! -d $i ] && [ -x $i ]
278+ then
279+ ln -sf $i $out/bin/$(basename $i)
280+ fi
281+ done
282+
266283 wrapProgram $out/bin/sdkmanager \
267284 --set JAVA_HOME ${jdk}
268285