2017-08-02 02:12:11 +02:00
|
|
|
{ pname, version, build, sha256Hash, meta }:
|
2016-07-07 14:25:35 +02:00
|
|
|
{ bash
|
|
|
|
, buildFHSUserEnv
|
|
|
|
, coreutils
|
|
|
|
, fetchurl
|
|
|
|
, findutils
|
2016-09-06 20:01:48 +02:00
|
|
|
, file
|
2016-07-07 14:25:35 +02:00
|
|
|
, git
|
2016-09-06 20:01:48 +02:00
|
|
|
, glxinfo
|
2016-07-07 14:25:35 +02:00
|
|
|
, gnugrep
|
|
|
|
, gnutar
|
|
|
|
, gzip
|
2016-12-15 10:41:18 +01:00
|
|
|
, fontconfig
|
|
|
|
, freetype
|
2016-09-06 20:01:48 +02:00
|
|
|
, libpulseaudio
|
|
|
|
, libX11
|
2016-12-15 10:41:18 +01:00
|
|
|
, libXext
|
|
|
|
, libXi
|
2016-07-07 14:25:35 +02:00
|
|
|
, libXrandr
|
2016-12-15 10:41:18 +01:00
|
|
|
, libXrender
|
|
|
|
, libXtst
|
2016-07-07 14:25:35 +02:00
|
|
|
, makeWrapper
|
2016-09-06 20:01:48 +02:00
|
|
|
, pciutils
|
2016-07-07 14:25:35 +02:00
|
|
|
, pkgsi686Linux
|
2016-09-06 20:01:48 +02:00
|
|
|
, setxkbmap
|
2016-07-07 14:25:35 +02:00
|
|
|
, stdenv
|
|
|
|
, unzip
|
|
|
|
, which
|
|
|
|
, writeTextFile
|
2016-09-06 20:01:48 +02:00
|
|
|
, xkeyboard_config
|
2016-07-07 14:25:35 +02:00
|
|
|
, zlib
|
2016-12-28 13:37:03 +01:00
|
|
|
, fontsConf
|
2016-07-07 14:25:35 +02:00
|
|
|
}:
|
|
|
|
|
|
|
|
let
|
|
|
|
androidStudio = stdenv.mkDerivation {
|
2018-01-09 01:21:48 +01:00
|
|
|
name = "${pname}-${version}";
|
2017-08-02 02:12:11 +02:00
|
|
|
|
|
|
|
src = fetchurl {
|
|
|
|
url = "https://dl.google.com/dl/android/studio/ide-zips/${version}/android-studio-ide-${build}-linux.zip";
|
|
|
|
sha256 = sha256Hash;
|
|
|
|
};
|
|
|
|
|
2016-07-07 14:25:35 +02:00
|
|
|
buildInputs = [
|
|
|
|
makeWrapper
|
|
|
|
unzip
|
|
|
|
];
|
|
|
|
installPhase = ''
|
|
|
|
cp -r . $out
|
2016-12-28 13:34:50 +01:00
|
|
|
wrapProgram $out/bin/studio.sh \
|
2018-01-09 01:21:48 +01:00
|
|
|
--set ANDROID_EMULATOR_USE_SYSTEM_LIBS 1 \
|
2016-12-28 13:34:50 +01:00
|
|
|
--set PATH "${stdenv.lib.makeBinPath [
|
2016-07-07 14:25:35 +02:00
|
|
|
|
2016-12-28 13:34:50 +01:00
|
|
|
# Checked in studio.sh
|
|
|
|
coreutils
|
|
|
|
findutils
|
|
|
|
gnugrep
|
|
|
|
which
|
2016-07-07 14:25:35 +02:00
|
|
|
|
2016-12-28 13:34:50 +01:00
|
|
|
# For Android emulator
|
|
|
|
file
|
|
|
|
glxinfo
|
|
|
|
pciutils
|
|
|
|
setxkbmap
|
2016-09-06 20:01:48 +02:00
|
|
|
|
2016-12-28 13:34:50 +01:00
|
|
|
# Used during setup wizard
|
|
|
|
gnutar
|
|
|
|
gzip
|
2016-07-07 14:25:35 +02:00
|
|
|
|
2016-12-28 13:34:50 +01:00
|
|
|
# Runtime stuff
|
|
|
|
git
|
|
|
|
]}" \
|
|
|
|
--prefix LD_LIBRARY_PATH : "${stdenv.lib.makeLibraryPath [
|
2016-12-28 13:31:19 +01:00
|
|
|
|
2016-12-28 13:34:50 +01:00
|
|
|
# Crash at startup without these
|
|
|
|
fontconfig
|
|
|
|
freetype
|
|
|
|
libXext
|
|
|
|
libXi
|
|
|
|
libXrender
|
|
|
|
libXtst
|
2016-12-28 13:31:19 +01:00
|
|
|
|
2016-12-28 13:34:50 +01:00
|
|
|
# Gradle wants libstdc++.so.6
|
|
|
|
stdenv.cc.cc.lib
|
|
|
|
# mksdcard wants 32 bit libstdc++.so.6
|
|
|
|
pkgsi686Linux.stdenv.cc.cc.lib
|
2016-09-06 20:01:48 +02:00
|
|
|
|
2016-12-28 13:34:50 +01:00
|
|
|
# aapt wants libz.so.1
|
|
|
|
zlib
|
|
|
|
pkgsi686Linux.zlib
|
|
|
|
# Support multiple monitors
|
|
|
|
libXrandr
|
2016-09-06 20:01:48 +02:00
|
|
|
|
2016-12-28 13:34:50 +01:00
|
|
|
# For Android emulator
|
|
|
|
libpulseaudio
|
|
|
|
libX11
|
|
|
|
|
|
|
|
]}" \
|
2016-12-28 13:37:03 +01:00
|
|
|
--set QT_XKB_CONFIG_ROOT "${xkeyboard_config}/share/X11/xkb" \
|
|
|
|
--set FONTCONFIG_FILE ${fontsConf}
|
2016-07-07 14:25:35 +02:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
# Android Studio downloads prebuilt binaries as part of the SDK. These tools
|
|
|
|
# (e.g. `mksdcard`) have `/lib/ld-linux.so.2` set as the interpreter. An FHS
|
|
|
|
# environment is used as a work around for that.
|
|
|
|
fhsEnv = buildFHSUserEnv {
|
2017-07-13 11:23:24 +02:00
|
|
|
name = "${pname}-fhs-env";
|
2016-07-07 14:25:35 +02:00
|
|
|
};
|
|
|
|
|
2017-07-30 20:32:04 +02:00
|
|
|
in
|
|
|
|
writeTextFile {
|
|
|
|
name = "${pname}-${version}";
|
|
|
|
destination = "/bin/${pname}";
|
|
|
|
executable = true;
|
|
|
|
text = ''
|
|
|
|
#!${bash}/bin/bash
|
|
|
|
${fhsEnv}/bin/${pname}-fhs-env ${androidStudio}/bin/studio.sh
|
|
|
|
'';
|
|
|
|
} // { inherit meta; }
|