2020-12-26 21:32:05 +00:00
|
|
|
{ channel, pname, version, build ? null, sha256Hash }:
|
2018-08-01 16:18:19 +00:00
|
|
|
|
2019-10-11 10:57:42 +00:00
|
|
|
{ alsaLib
|
|
|
|
, bash
|
2016-07-07 12:25:35 +00:00
|
|
|
, buildFHSUserEnv
|
2019-11-04 13:53:02 +00:00
|
|
|
, cacert
|
2016-07-07 12:25:35 +00:00
|
|
|
, coreutils
|
2019-10-11 10:57:42 +00:00
|
|
|
, dbus
|
|
|
|
, expat
|
2016-07-07 12:25:35 +00:00
|
|
|
, 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
|
2019-12-19 07:45:37 +00:00
|
|
|
, libuuid
|
2016-09-06 18:01:48 +00:00
|
|
|
, libX11
|
2019-10-11 10:57:42 +00:00
|
|
|
, libxcb
|
|
|
|
, libXcomposite
|
|
|
|
, libXcursor
|
|
|
|
, libXdamage
|
2016-12-15 09:41:18 +00:00
|
|
|
, libXext
|
2019-10-11 10:57:42 +00:00
|
|
|
, libXfixes
|
2016-12-15 09:41:18 +00:00
|
|
|
, 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
|
2021-02-08 00:09:59 +00:00
|
|
|
, ncurses5
|
2019-10-11 10:57:42 +00:00
|
|
|
, nspr
|
|
|
|
, nss
|
2016-09-06 18:01:48 +00:00
|
|
|
, pciutils
|
2016-07-07 12:25:35 +00:00
|
|
|
, pkgsi686Linux
|
2020-04-21 20:48:47 +00:00
|
|
|
, ps
|
2016-09-06 18:01:48 +00:00
|
|
|
, setxkbmap
|
2021-01-11 07:54:33 +00:00
|
|
|
, lib
|
2016-07-07 12:25:35 +00:00
|
|
|
, stdenv
|
2019-10-11 10:57:42 +00:00
|
|
|
, systemd
|
2016-07-07 12:25:35 +00:00
|
|
|
, unzip
|
|
|
|
, which
|
2018-09-02 16:41:20 +00:00
|
|
|
, runCommand
|
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}";
|
2020-12-26 21:32:05 +00:00
|
|
|
filename = "android-studio-" + (if (build != null) then "ide-${build}" else version) + "-linux.tar.gz";
|
|
|
|
|
2018-09-02 16:41:20 +00:00
|
|
|
androidStudio = stdenv.mkDerivation {
|
2019-09-04 17:10:00 +00:00
|
|
|
name = "${drvName}-unwrapped";
|
2017-08-02 00:12:11 +00:00
|
|
|
|
|
|
|
src = fetchurl {
|
2020-12-26 21:32:05 +00:00
|
|
|
url = "https://dl.google.com/dl/android/studio/ide-zips/${version}/${filename}";
|
2017-08-02 00:12:11 +00:00
|
|
|
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 \
|
2021-02-10 17:30:03 +00:00
|
|
|
--set JAVA_HOME "$out/jre" \
|
|
|
|
--set QT_XKB_CONFIG_ROOT "${xkeyboard_config}/share/X11/xkb" \
|
|
|
|
--set FONTCONFIG_FILE ${fontsConf} \
|
2021-01-15 13:21:58 +00:00
|
|
|
--prefix PATH : "${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
|
2020-04-21 20:48:47 +00:00
|
|
|
ps
|
2016-12-28 12:34:50 +00:00
|
|
|
]}" \
|
2021-01-15 13:21:58 +00:00
|
|
|
--prefix LD_LIBRARY_PATH : "${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
|
2019-10-11 10:57:42 +00:00
|
|
|
alsaLib
|
|
|
|
dbus
|
|
|
|
expat
|
2016-12-28 12:34:50 +00:00
|
|
|
libpulseaudio
|
2019-12-19 07:45:37 +00:00
|
|
|
libuuid
|
2016-12-28 12:34:50 +00:00
|
|
|
libX11
|
2019-10-11 10:57:42 +00:00
|
|
|
libxcb
|
|
|
|
libXcomposite
|
|
|
|
libXcursor
|
|
|
|
libXdamage
|
|
|
|
libXfixes
|
2018-06-30 07:16:10 +00:00
|
|
|
libGL
|
2019-10-11 10:57:42 +00:00
|
|
|
nspr
|
|
|
|
nss
|
|
|
|
systemd
|
2016-12-28 12:34:50 +00:00
|
|
|
|
2018-03-13 13:08:09 +00:00
|
|
|
# For GTKLookAndFeel
|
|
|
|
gtk2
|
|
|
|
gnome_vfs
|
|
|
|
glib
|
|
|
|
GConf
|
2021-02-10 17:30:03 +00:00
|
|
|
]}"
|
2021-02-08 00:09:59 +00:00
|
|
|
|
|
|
|
# AS launches LLDBFrontend with a custom LD_LIBRARY_PATH
|
|
|
|
wrapProgram $out/bin/lldb/bin/LLDBFrontend --prefix LD_LIBRARY_PATH : "${lib.makeLibraryPath [
|
|
|
|
ncurses5
|
|
|
|
zlib
|
|
|
|
]}"
|
2016-07-07 12:25:35 +00:00
|
|
|
'';
|
2018-09-02 16:41:20 +00:00
|
|
|
};
|
2018-08-31 10:05:24 +00:00
|
|
|
|
2021-02-08 00:09:59 +00:00
|
|
|
# Causes the shebangs in interpreter scripts deployed to mobile devices to be patched, which Android does not understand
|
|
|
|
dontPatchShebangs = true;
|
|
|
|
|
2018-09-02 16:41:20 +00: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 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";
|
2019-11-04 13:53:02 +00:00
|
|
|
multiPkgs = pkgs: [
|
2021-02-08 00:09:59 +00:00
|
|
|
ncurses5
|
2019-11-04 13:53:02 +00:00
|
|
|
|
|
|
|
# Flutter can only search for certs Fedora-way.
|
|
|
|
(runCommand "fedoracert" {}
|
|
|
|
''
|
|
|
|
mkdir -p $out/etc/pki/tls/
|
|
|
|
ln -s ${cacert}/etc/ssl/certs $out/etc/pki/tls/certs
|
|
|
|
'')
|
|
|
|
];
|
2016-07-07 12:25:35 +00:00
|
|
|
};
|
2018-09-02 16:41:20 +00:00
|
|
|
in runCommand
|
2019-09-04 17:10:00 +00:00
|
|
|
drvName
|
2018-09-02 16:41:20 +00:00
|
|
|
{
|
|
|
|
startScript = ''
|
2017-07-30 18:32:04 +00:00
|
|
|
#!${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-09-02 16:41:20 +00:00
|
|
|
preferLocalBuild = true;
|
|
|
|
allowSubstitutes = false;
|
2019-04-02 20:52:23 +00:00
|
|
|
passthru = {
|
|
|
|
unwrapped = androidStudio;
|
|
|
|
};
|
2021-01-11 07:54:33 +00:00
|
|
|
meta = with lib; {
|
2018-09-02 16:41:20 +00:00
|
|
|
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"
|
2020-04-01 01:11:51 +00:00
|
|
|
then "https://developer.android.com/studio/index.html"
|
|
|
|
else "https://developer.android.com/studio/preview/index.html";
|
2020-04-12 15:23:46 +00:00
|
|
|
license = with licenses; [ asl20 unfree ]; # The code is under Apache-2.0, but:
|
|
|
|
# If one selects Help -> Licenses in Android Studio, the dialog shows the following:
|
|
|
|
# "Android Studio includes proprietary code subject to separate license,
|
|
|
|
# including JetBrains CLion(R) (www.jetbrains.com/clion) and IntelliJ(R)
|
|
|
|
# IDEA Community Edition (www.jetbrains.com/idea)."
|
|
|
|
# Also: For actual development the Android SDK is required and the Google
|
|
|
|
# binaries are also distributed as proprietary software (unlike the
|
|
|
|
# source-code itself).
|
2018-09-02 16:41:20 +00:00
|
|
|
platforms = [ "x86_64-linux" ];
|
2020-07-20 20:45:47 +00:00
|
|
|
maintainers = with maintainers; rec {
|
2020-07-21 16:53:56 +00:00
|
|
|
stable = [ meutraa ];
|
2020-08-31 22:08:14 +00:00
|
|
|
beta = [ meutraa ];
|
2020-07-21 16:53:56 +00:00
|
|
|
canary = [ meutraa ];
|
2020-07-20 20:45:47 +00:00
|
|
|
dev = canary;
|
|
|
|
}."${channel}";
|
2018-09-02 16:41:20 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
''
|
2018-08-31 10:05:24 +00:00
|
|
|
mkdir -p $out/{bin,share/pixmaps}
|
|
|
|
|
2018-09-02 16:41:20 +00:00
|
|
|
echo -n "$startScript" > $out/bin/${pname}
|
|
|
|
chmod +x $out/bin/${pname}
|
2019-01-17 17:41:37 +00:00
|
|
|
|
2018-09-02 16:41:20 +00:00
|
|
|
ln -s ${androidStudio}/bin/studio.png $out/share/pixmaps/${drvName}.png
|
|
|
|
ln -s ${desktopItem}/share/applications $out/share/applications
|
|
|
|
''
|