2018-08-02 16:31:31 +02:00
|
|
|
{ channel, pname, version, build, sha256Hash }:
|
2018-08-01 18:18:19 +02:00
|
|
|
|
2019-10-11 12:57:42 +02:00
|
|
|
{ alsaLib
|
|
|
|
, bash
|
2016-07-07 14:25:35 +02:00
|
|
|
, buildFHSUserEnv
|
|
|
|
, coreutils
|
2019-10-11 12:57:42 +02:00
|
|
|
, dbus
|
|
|
|
, expat
|
2016-07-07 14:25:35 +02:00
|
|
|
, fetchurl
|
|
|
|
, findutils
|
2016-09-06 20:01:48 +02:00
|
|
|
, file
|
2018-04-09 22:43:25 +02:00
|
|
|
, fontsConf
|
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
|
2018-04-09 22:43:25 +02:00
|
|
|
, gnused
|
2016-07-07 14:25:35 +02:00
|
|
|
, gnutar
|
2018-04-09 22:43:25 +02:00
|
|
|
, gtk2, gnome_vfs, glib, GConf
|
2016-07-07 14:25:35 +02:00
|
|
|
, gzip
|
2016-12-15 10:41:18 +01:00
|
|
|
, fontconfig
|
|
|
|
, freetype
|
2016-09-06 20:01:48 +02:00
|
|
|
, libpulseaudio
|
2018-06-30 09:16:10 +02:00
|
|
|
, libGL
|
2016-09-06 20:01:48 +02:00
|
|
|
, libX11
|
2019-10-11 12:57:42 +02:00
|
|
|
, libxcb
|
|
|
|
, libXcomposite
|
|
|
|
, libXcursor
|
|
|
|
, libXdamage
|
2016-12-15 10:41:18 +01:00
|
|
|
, libXext
|
2019-10-11 12:57:42 +02:00
|
|
|
, libXfixes
|
2016-12-15 10:41:18 +01:00
|
|
|
, 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
|
2019-10-11 12:57:42 +02:00
|
|
|
, nspr
|
|
|
|
, nss
|
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
|
2019-10-11 12:57:42 +02:00
|
|
|
, systemd
|
2016-07-07 14:25:35 +02:00
|
|
|
, unzip
|
|
|
|
, which
|
2018-09-02 18:41:20 +02:00
|
|
|
, runCommand
|
2016-09-06 20:01:48 +02:00
|
|
|
, xkeyboard_config
|
2016-07-07 14:25:35 +02:00
|
|
|
, zlib
|
2018-08-31 12:05:24 +02:00
|
|
|
, makeDesktopItem
|
2016-07-07 14:25:35 +02:00
|
|
|
}:
|
|
|
|
|
|
|
|
let
|
2018-08-01 18:40:07 +02:00
|
|
|
drvName = "android-studio-${channel}-${version}";
|
2018-09-02 18:41:20 +02:00
|
|
|
androidStudio = stdenv.mkDerivation {
|
2019-09-04 19:10:00 +02:00
|
|
|
name = "${drvName}-unwrapped";
|
2017-08-02 02:12:11 +02:00
|
|
|
|
|
|
|
src = fetchurl {
|
2019-04-18 20:24:43 +02:00
|
|
|
url = "https://dl.google.com/dl/android/studio/ide-zips/${version}/android-studio-ide-${build}-linux.tar.gz";
|
2017-08-02 02:12:11 +02:00
|
|
|
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 \
|
2019-05-21 23:10:01 +02:00
|
|
|
--prefix 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
|
2018-04-09 22:43:25 +02:00
|
|
|
gnused
|
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
|
2019-10-11 12:57:42 +02:00
|
|
|
alsaLib
|
|
|
|
dbus
|
|
|
|
expat
|
2016-12-28 13:34:50 +01:00
|
|
|
libpulseaudio
|
|
|
|
libX11
|
2019-10-11 12:57:42 +02:00
|
|
|
libxcb
|
|
|
|
libXcomposite
|
|
|
|
libXcursor
|
|
|
|
libXdamage
|
|
|
|
libXfixes
|
2018-06-30 09:16:10 +02:00
|
|
|
libGL
|
2019-10-11 12:57:42 +02:00
|
|
|
nspr
|
|
|
|
nss
|
|
|
|
systemd
|
2016-12-28 13:34:50 +01:00
|
|
|
|
2018-03-13 14:08:09 +01:00
|
|
|
# For GTKLookAndFeel
|
|
|
|
gtk2
|
|
|
|
gnome_vfs
|
|
|
|
glib
|
|
|
|
GConf
|
2016-12-28 13:34:50 +01:00
|
|
|
]}" \
|
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
|
|
|
'';
|
2018-09-02 18:41:20 +02:00
|
|
|
};
|
2018-08-31 12:05:24 +02:00
|
|
|
|
2018-09-02 18:41:20 +02:00
|
|
|
desktopItem = makeDesktopItem {
|
|
|
|
name = drvName;
|
|
|
|
exec = pname;
|
|
|
|
icon = drvName;
|
|
|
|
desktopName = "Android Studio (${channel} channel)";
|
|
|
|
comment = "The official Android IDE";
|
|
|
|
categories = "Development;IDE;";
|
|
|
|
startupNotify = "true";
|
|
|
|
extraEntries="StartupWMClass=jetbrains-studio";
|
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 {
|
2018-08-01 18:40:07 +02:00
|
|
|
name = "${drvName}-fhs-env";
|
2018-02-26 00:03:37 +01:00
|
|
|
multiPkgs = pkgs: [ pkgs.ncurses5 ];
|
2016-07-07 14:25:35 +02:00
|
|
|
};
|
2018-09-02 18:41:20 +02:00
|
|
|
in runCommand
|
2019-09-04 19:10:00 +02:00
|
|
|
drvName
|
2018-09-02 18:41:20 +02:00
|
|
|
{
|
|
|
|
startScript = ''
|
2017-07-30 20:32:04 +02:00
|
|
|
#!${bash}/bin/bash
|
2018-08-01 18:40:07 +02:00
|
|
|
${fhsEnv}/bin/${drvName}-fhs-env ${androidStudio}/bin/studio.sh
|
2018-08-02 16:31:31 +02:00
|
|
|
'';
|
2018-09-02 18:41:20 +02:00
|
|
|
preferLocalBuild = true;
|
|
|
|
allowSubstitutes = false;
|
2019-04-02 22:52:23 +02:00
|
|
|
passthru = {
|
|
|
|
unwrapped = androidStudio;
|
|
|
|
};
|
2018-09-02 18:41:20 +02:00
|
|
|
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 ];
|
|
|
|
};
|
|
|
|
}
|
|
|
|
''
|
2018-08-31 12:05:24 +02:00
|
|
|
mkdir -p $out/{bin,share/pixmaps}
|
|
|
|
|
2018-09-02 18:41:20 +02:00
|
|
|
echo -n "$startScript" > $out/bin/${pname}
|
|
|
|
chmod +x $out/bin/${pname}
|
2019-01-17 18:41:37 +01:00
|
|
|
|
2018-09-02 18:41:20 +02:00
|
|
|
ln -s ${androidStudio}/bin/studio.png $out/share/pixmaps/${drvName}.png
|
|
|
|
ln -s ${desktopItem}/share/applications $out/share/applications
|
|
|
|
''
|