2018-08-02 14:31:31 +00:00
|
|
|
{ channel, pname, version, build, sha256Hash }:
|
2018-08-01 16:18:19 +00:00
|
|
|
|
2016-07-07 12:25:35 +00:00
|
|
|
{ bash
|
|
|
|
, buildFHSUserEnv
|
|
|
|
, coreutils
|
|
|
|
, fetchurl
|
|
|
|
, findutils
|
2016-09-06 18:01:48 +00:00
|
|
|
, file
|
2018-04-09 20:43:25 +00:00
|
|
|
, fontsConf
|
2016-07-07 12:25:35 +00:00
|
|
|
, git
|
2016-09-06 18:01:48 +00:00
|
|
|
, glxinfo
|
2016-07-07 12:25:35 +00:00
|
|
|
, gnugrep
|
2018-04-09 20:43:25 +00:00
|
|
|
, gnused
|
2016-07-07 12:25:35 +00:00
|
|
|
, gnutar
|
2018-04-09 20:43:25 +00:00
|
|
|
, gtk2, gnome_vfs, glib, GConf
|
2016-07-07 12:25:35 +00:00
|
|
|
, gzip
|
2016-12-15 09:41:18 +00:00
|
|
|
, fontconfig
|
|
|
|
, freetype
|
2016-09-06 18:01:48 +00:00
|
|
|
, libpulseaudio
|
2018-06-30 07:16:10 +00:00
|
|
|
, libGL
|
2016-09-06 18:01:48 +00:00
|
|
|
, libX11
|
2016-12-15 09:41:18 +00:00
|
|
|
, libXext
|
|
|
|
, libXi
|
2016-07-07 12:25:35 +00:00
|
|
|
, libXrandr
|
2016-12-15 09:41:18 +00:00
|
|
|
, libXrender
|
|
|
|
, libXtst
|
2016-07-07 12:25:35 +00:00
|
|
|
, makeWrapper
|
2016-09-06 18:01:48 +00:00
|
|
|
, pciutils
|
2016-07-07 12:25:35 +00:00
|
|
|
, pkgsi686Linux
|
2016-09-06 18:01:48 +00:00
|
|
|
, setxkbmap
|
2016-07-07 12:25:35 +00:00
|
|
|
, stdenv
|
|
|
|
, unzip
|
|
|
|
, which
|
|
|
|
, writeTextFile
|
2016-09-06 18:01:48 +00:00
|
|
|
, xkeyboard_config
|
2016-07-07 12:25:35 +00:00
|
|
|
, zlib
|
2018-08-31 10:05:24 +00:00
|
|
|
, makeDesktopItem
|
2016-07-07 12:25:35 +00:00
|
|
|
}:
|
|
|
|
|
|
|
|
let
|
2018-08-01 16:40:07 +00:00
|
|
|
drvName = "android-studio-${channel}-${version}";
|
2018-08-31 10:05:24 +00:00
|
|
|
androidStudio = stdenv.mkDerivation rec {
|
2018-08-01 16:40:07 +00:00
|
|
|
name = drvName;
|
2017-08-02 00:12:11 +00: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 12:25:35 +00:00
|
|
|
buildInputs = [
|
|
|
|
makeWrapper
|
|
|
|
unzip
|
|
|
|
];
|
|
|
|
installPhase = ''
|
|
|
|
cp -r . $out
|
2016-12-28 12:34:50 +00:00
|
|
|
wrapProgram $out/bin/studio.sh \
|
2018-01-09 00:21:48 +00:00
|
|
|
--set ANDROID_EMULATOR_USE_SYSTEM_LIBS 1 \
|
2016-12-28 12:34:50 +00:00
|
|
|
--set PATH "${stdenv.lib.makeBinPath [
|
2016-07-07 12:25:35 +00:00
|
|
|
|
2016-12-28 12:34:50 +00:00
|
|
|
# Checked in studio.sh
|
|
|
|
coreutils
|
|
|
|
findutils
|
|
|
|
gnugrep
|
|
|
|
which
|
2018-04-09 20:43:25 +00:00
|
|
|
gnused
|
2016-07-07 12:25:35 +00:00
|
|
|
|
2016-12-28 12:34:50 +00:00
|
|
|
# For Android emulator
|
|
|
|
file
|
|
|
|
glxinfo
|
|
|
|
pciutils
|
|
|
|
setxkbmap
|
2016-09-06 18:01:48 +00:00
|
|
|
|
2016-12-28 12:34:50 +00:00
|
|
|
# Used during setup wizard
|
|
|
|
gnutar
|
|
|
|
gzip
|
2016-07-07 12:25:35 +00:00
|
|
|
|
2016-12-28 12:34:50 +00:00
|
|
|
# Runtime stuff
|
|
|
|
git
|
|
|
|
]}" \
|
|
|
|
--prefix LD_LIBRARY_PATH : "${stdenv.lib.makeLibraryPath [
|
2016-12-28 12:31:19 +00:00
|
|
|
|
2016-12-28 12:34:50 +00:00
|
|
|
# Crash at startup without these
|
|
|
|
fontconfig
|
|
|
|
freetype
|
|
|
|
libXext
|
|
|
|
libXi
|
|
|
|
libXrender
|
|
|
|
libXtst
|
2016-12-28 12:31:19 +00:00
|
|
|
|
2016-12-28 12:34:50 +00: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 18:01:48 +00:00
|
|
|
|
2016-12-28 12:34:50 +00:00
|
|
|
# aapt wants libz.so.1
|
|
|
|
zlib
|
|
|
|
pkgsi686Linux.zlib
|
|
|
|
# Support multiple monitors
|
|
|
|
libXrandr
|
2016-09-06 18:01:48 +00:00
|
|
|
|
2016-12-28 12:34:50 +00:00
|
|
|
# For Android emulator
|
|
|
|
libpulseaudio
|
|
|
|
libX11
|
2018-06-30 07:16:10 +00:00
|
|
|
libGL
|
2016-12-28 12:34:50 +00:00
|
|
|
|
2018-03-13 13:08:09 +00:00
|
|
|
# For GTKLookAndFeel
|
|
|
|
gtk2
|
|
|
|
gnome_vfs
|
|
|
|
glib
|
|
|
|
GConf
|
2016-12-28 12:34:50 +00:00
|
|
|
]}" \
|
2016-12-28 12:37:03 +00:00
|
|
|
--set QT_XKB_CONFIG_ROOT "${xkeyboard_config}/share/X11/xkb" \
|
|
|
|
--set FONTCONFIG_FILE ${fontsConf}
|
2018-08-31 10:05:24 +00:00
|
|
|
|
|
|
|
install -Dm644 bin/studio.png $out/share/pixmaps/${drvName}.png
|
|
|
|
ln -s ${desktopItem}/share/applications $out/share/applications
|
2016-07-07 12:25:35 +00:00
|
|
|
'';
|
2018-08-31 10:05:24 +00:00
|
|
|
|
|
|
|
desktopItem = makeDesktopItem rec {
|
|
|
|
name = drvName;
|
|
|
|
exec = pname;
|
|
|
|
icon = drvName;
|
|
|
|
desktopName = "Android Studio";
|
|
|
|
comment = "The official Android IDE";
|
|
|
|
categories = "Development;IDE;";
|
|
|
|
};
|
|
|
|
|
2016-07-07 12:25:35 +00: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 {
|
2018-08-01 16:40:07 +00:00
|
|
|
name = "${drvName}-fhs-env";
|
2018-02-25 23:03:37 +00:00
|
|
|
multiPkgs = pkgs: [ pkgs.ncurses5 ];
|
2016-07-07 12:25:35 +00:00
|
|
|
};
|
|
|
|
|
2018-08-31 10:05:24 +00:00
|
|
|
wrapper = writeTextFile {
|
2018-08-01 16:40:07 +00:00
|
|
|
name = "${drvName}-wrapper";
|
|
|
|
# TODO: Rename preview -> beta (and add -stable suffix?):
|
2017-07-30 18:32:04 +00:00
|
|
|
destination = "/bin/${pname}";
|
|
|
|
executable = true;
|
|
|
|
text = ''
|
|
|
|
#!${bash}/bin/bash
|
2018-08-01 16:40:07 +00:00
|
|
|
${fhsEnv}/bin/${drvName}-fhs-env ${androidStudio}/bin/studio.sh
|
2018-08-02 14:31:31 +00:00
|
|
|
'';
|
2018-08-31 10:05:24 +00:00
|
|
|
};
|
|
|
|
in stdenv.mkDerivation {
|
|
|
|
name = "${drvName}-with-desktop-item";
|
|
|
|
|
|
|
|
buildCommand = ''
|
|
|
|
mkdir -p $out/{bin,share/pixmaps}
|
|
|
|
ln -s ${wrapper}/bin/${pname} $out/bin/${pname}
|
|
|
|
|
|
|
|
ln -s ${androidStudio}/share/pixmaps/${drvName}.png $out/share/pixmaps/${drvName}.png
|
|
|
|
ln -s ${androidStudio}/share/applications $out/share/applications
|
|
|
|
'';
|
|
|
|
|
|
|
|
meta = with stdenv.lib; {
|
|
|
|
description = "The Official IDE for Android (${channel} channel)";
|
|
|
|
longDescription = ''
|
|
|
|
Android Studio is the official IDE for Android app development, based on
|
|
|
|
IntelliJ IDEA.
|
|
|
|
'';
|
|
|
|
homepage = if channel == "stable"
|
|
|
|
then https://developer.android.com/studio/index.html
|
|
|
|
else https://developer.android.com/studio/preview/index.html;
|
|
|
|
license = licenses.asl20;
|
|
|
|
platforms = [ "x86_64-linux" ];
|
|
|
|
maintainers = with maintainers; [ primeos ];
|
|
|
|
};
|
|
|
|
}
|