1{
2 deployAndroidPackage,
3 lib,
4 stdenv,
5 package,
6 os,
7 arch,
8 autoPatchelfHook,
9 makeWrapper,
10 pkgs,
11 pkgsi686Linux,
12 postInstall,
13 meta,
14}:
15
16deployAndroidPackage {
17 inherit package os arch;
18 nativeBuildInputs = [ makeWrapper ] ++ lib.optionals (os == "linux") [ autoPatchelfHook ];
19 buildInputs =
20 lib.optionals (os == "linux") (
21 with pkgs;
22 [
23 glibc
24 libcxx
25 libGL
26 libpulseaudio
27 libtiff
28 libuuid
29 zlib
30 libbsd
31 ncurses5
32 libdrm
33 stdenv.cc.cc
34 expat
35 freetype
36 nss
37 nspr
38 alsa-lib
39 waylandpp.lib
40 ]
41 )
42 ++ (with pkgs.xorg; [
43 libX11
44 libXext
45 libXdamage
46 libXfixes
47 libxcb
48 libXcomposite
49 libXcursor
50 libXi
51 libXrender
52 libXtst
53 libICE
54 libSM
55 libxkbfile
56 libxshmfence
57 ])
58 ++ lib.optional (os == "linux" && stdenv.isx86_64) pkgsi686Linux.glibc;
59 patchInstructions =
60 (lib.optionalString (os == "linux") ''
61 addAutoPatchelfSearchPath $packageBaseDir/lib
62 addAutoPatchelfSearchPath $packageBaseDir/lib64
63 addAutoPatchelfSearchPath $packageBaseDir/lib64/qt/lib
64 # autoPatchelf is not detecting libuuid :(
65 addAutoPatchelfSearchPath ${pkgs.libuuid.out}/lib
66
67 # This library is linked against a version of libtiff that nixpkgs doesn't have
68 for file in $out/libexec/android-sdk/emulator/*/qt/plugins/imageformats/libqtiffAndroidEmu.so; do
69 patchelf --replace-needed libtiff.so.5 libtiff.so "$file" || true
70 done
71
72 autoPatchelf $out
73
74 # Wrap emulator so that it can load required libraries at runtime
75 wrapProgram $out/libexec/android-sdk/emulator/emulator \
76 --prefix LD_LIBRARY_PATH : ${
77 lib.makeLibraryPath [
78 pkgs.dbus
79 pkgs.systemd
80 ]
81 } \
82 --set QT_XKB_CONFIG_ROOT ${pkgs.xkeyboard_config}/share/X11/xkb \
83 --set QTCOMPOSE ${pkgs.xorg.libX11.out}/share/X11/locale
84 '')
85 + ''
86 mkdir -p $out/bin
87 cd $out/bin
88 find $out/libexec/android-sdk/emulator -type f -executable -mindepth 1 -maxdepth 1 | while read i; do
89 ln -s $i
90 done
91
92 cd $out/libexec/android-sdk
93 ${postInstall}
94 '';
95 dontMoveLib64 = true;
96
97 inherit meta;
98}