2021-07-31 12:09:23 +02:00
|
|
|
{ channel, pname, version, sha256Hash }:
|
2018-08-01 18:18:19 +02:00
|
|
|
|
2021-06-10 04:57:09 +02:00
|
|
|
{ alsa-lib
|
2019-10-11 12:57:42 +02:00
|
|
|
, bash
|
2023-04-11 12:52:27 +02:00
|
|
|
, buildFHSEnv
|
2019-11-04 14:53:02 +01:00
|
|
|
, cacert
|
2016-07-07 14:25:35 +02:00
|
|
|
, coreutils
|
2019-10-11 12:57:42 +02:00
|
|
|
, dbus
|
2022-05-03 08:23:59 +02:00
|
|
|
, e2fsprogs
|
2019-10-11 12:57:42 +02:00
|
|
|
, 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
|
2024-04-11 23:19:01 +02:00
|
|
|
, libbsd
|
2016-09-06 20:01:48 +02:00
|
|
|
, libpulseaudio
|
2018-06-30 09:16:10 +02:00
|
|
|
, libGL
|
2024-04-11 23:19:01 +02:00
|
|
|
, libdrm
|
|
|
|
, libpng
|
2019-12-19 08:45:37 +01:00
|
|
|
, libuuid
|
2016-09-06 20:01:48 +02:00
|
|
|
, libX11
|
2019-10-11 12:57:42 +02:00
|
|
|
, libxcb
|
2024-04-11 23:19:01 +02:00
|
|
|
, libxkbcommon
|
|
|
|
, xcbutilwm
|
|
|
|
, xcbutilrenderutil
|
|
|
|
, xcbutilkeysyms
|
|
|
|
, xcbutilimage
|
|
|
|
, xcbutilcursor
|
|
|
|
, libxkbfile
|
2019-10-11 12:57:42 +02:00
|
|
|
, 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
|
2021-02-08 01:09:59 +01:00
|
|
|
, ncurses5
|
2019-10-11 12:57:42 +02:00
|
|
|
, nspr
|
2023-06-11 00:35:08 +02:00
|
|
|
, nss_latest
|
2016-09-06 20:01:48 +02:00
|
|
|
, pciutils
|
2016-07-07 14:25:35 +02:00
|
|
|
, pkgsi686Linux
|
2020-04-21 22:48:47 +02:00
|
|
|
, ps
|
2016-09-06 20:01:48 +02:00
|
|
|
, setxkbmap
|
2021-01-11 08:54:33 +01:00
|
|
|
, lib
|
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
|
2021-12-17 01:29:22 +01:00
|
|
|
, usbutils
|
2016-07-07 14:25:35 +02:00
|
|
|
, which
|
2018-09-02 18:41:20 +02:00
|
|
|
, runCommand
|
2016-09-06 20:01:48 +02:00
|
|
|
, xkeyboard_config
|
2024-04-11 23:19:01 +02:00
|
|
|
, xorg
|
2016-07-07 14:25:35 +02:00
|
|
|
, zlib
|
2018-08-31 12:05:24 +02:00
|
|
|
, makeDesktopItem
|
2022-04-12 19:04:53 +02:00
|
|
|
, tiling_wm # if we are using a tiling wm, need to set _JAVA_AWT_WM_NONREPARENTING in wrapper
|
2016-07-07 14:25:35 +02:00
|
|
|
}:
|
|
|
|
|
|
|
|
let
|
2018-08-01 18:40:07 +02:00
|
|
|
drvName = "android-studio-${channel}-${version}";
|
2021-07-31 12:09:23 +02:00
|
|
|
filename = "android-studio-${version}-linux.tar.gz";
|
2020-12-26 22:32:05 +01:00
|
|
|
|
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 {
|
2020-12-26 22:32:05 +01:00
|
|
|
url = "https://dl.google.com/dl/android/studio/ide-zips/${version}/${filename}";
|
2017-08-02 02:12:11 +02:00
|
|
|
sha256 = sha256Hash;
|
|
|
|
};
|
|
|
|
|
2021-08-02 16:29:56 +02:00
|
|
|
nativeBuildInputs = [
|
|
|
|
unzip
|
2016-07-07 14:25:35 +02:00
|
|
|
makeWrapper
|
|
|
|
];
|
2021-08-02 16:29:56 +02:00
|
|
|
|
|
|
|
# Causes the shebangs in interpreter scripts deployed to mobile devices to be patched, which Android does not understand
|
|
|
|
dontPatchShebangs = true;
|
|
|
|
|
2016-07-07 14:25:35 +02:00
|
|
|
installPhase = ''
|
|
|
|
cp -r . $out
|
2016-12-28 13:34:50 +01:00
|
|
|
wrapProgram $out/bin/studio.sh \
|
2023-01-27 15:09:17 +01:00
|
|
|
--set-default JAVA_HOME "$out/jbr" \
|
2018-01-09 01:21:48 +01:00
|
|
|
--set ANDROID_EMULATOR_USE_SYSTEM_LIBS 1 \
|
2021-02-10 18:30:03 +01:00
|
|
|
--set QT_XKB_CONFIG_ROOT "${xkeyboard_config}/share/X11/xkb" \
|
2022-04-12 19:04:53 +02:00
|
|
|
${lib.optionalString tiling_wm "--set _JAVA_AWT_WM_NONREPARENTING 1"} \
|
2021-02-10 18:30:03 +01:00
|
|
|
--set FONTCONFIG_FILE ${fontsConf} \
|
2021-01-15 14:21:58 +01:00
|
|
|
--prefix PATH : "${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
|
2020-04-21 22:48:47 +02:00
|
|
|
ps
|
2021-12-17 01:29:22 +01:00
|
|
|
usbutils
|
2016-12-28 13:34:50 +01:00
|
|
|
]}" \
|
2021-01-15 14:21:58 +01:00
|
|
|
--prefix LD_LIBRARY_PATH : "${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
|
|
|
|
2022-05-03 08:23:59 +02:00
|
|
|
# No crash, but attempted to load at startup
|
|
|
|
e2fsprogs
|
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
|
2021-06-10 04:57:09 +02:00
|
|
|
alsa-lib
|
2019-10-11 12:57:42 +02:00
|
|
|
dbus
|
|
|
|
expat
|
2024-04-11 23:19:01 +02:00
|
|
|
libbsd
|
2016-12-28 13:34:50 +01:00
|
|
|
libpulseaudio
|
2019-12-19 08:45:37 +01:00
|
|
|
libuuid
|
2016-12-28 13:34:50 +01:00
|
|
|
libX11
|
2019-10-11 12:57:42 +02:00
|
|
|
libxcb
|
2024-04-11 23:19:01 +02:00
|
|
|
libxkbcommon
|
|
|
|
xcbutilwm
|
|
|
|
xcbutilrenderutil
|
|
|
|
xcbutilkeysyms
|
|
|
|
xcbutilimage
|
|
|
|
xcbutilcursor
|
|
|
|
xorg.libICE
|
|
|
|
xorg.libSM
|
|
|
|
libxkbfile
|
2019-10-11 12:57:42 +02:00
|
|
|
libXcomposite
|
|
|
|
libXcursor
|
|
|
|
libXdamage
|
|
|
|
libXfixes
|
2018-06-30 09:16:10 +02:00
|
|
|
libGL
|
2024-04-11 23:19:01 +02:00
|
|
|
libdrm
|
|
|
|
libpng
|
2019-10-11 12:57:42 +02:00
|
|
|
nspr
|
2023-06-11 00:35:08 +02:00
|
|
|
nss_latest
|
2019-10-11 12:57:42 +02:00
|
|
|
systemd
|
2016-12-28 13:34:50 +01:00
|
|
|
|
2018-03-13 14:08:09 +01:00
|
|
|
# For GTKLookAndFeel
|
|
|
|
gtk2
|
|
|
|
gnome_vfs
|
|
|
|
glib
|
|
|
|
GConf
|
2021-02-10 18:30:03 +01:00
|
|
|
]}"
|
2021-02-08 01:09:59 +01:00
|
|
|
|
|
|
|
# AS launches LLDBFrontend with a custom LD_LIBRARY_PATH
|
2021-05-05 07:45:26 +02:00
|
|
|
wrapProgram $(find $out -name LLDBFrontend) --prefix LD_LIBRARY_PATH : "${lib.makeLibraryPath [
|
2021-02-08 01:09:59 +01:00
|
|
|
ncurses5
|
|
|
|
zlib
|
|
|
|
]}"
|
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 {
|
2022-02-25 04:26:52 +01:00
|
|
|
name = pname;
|
2018-09-02 18:41:20 +02:00
|
|
|
exec = pname;
|
2022-02-25 04:26:52 +01:00
|
|
|
icon = pname;
|
2018-09-02 18:41:20 +02:00
|
|
|
desktopName = "Android Studio (${channel} channel)";
|
|
|
|
comment = "The official Android IDE";
|
2022-02-22 15:56:15 +01:00
|
|
|
categories = [ "Development" "IDE" ];
|
|
|
|
startupNotify = true;
|
|
|
|
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.
|
2023-04-11 12:52:27 +02:00
|
|
|
fhsEnv = buildFHSEnv {
|
2018-08-01 18:40:07 +02:00
|
|
|
name = "${drvName}-fhs-env";
|
2019-11-04 14:53:02 +01:00
|
|
|
multiPkgs = pkgs: [
|
2021-02-08 01:09:59 +01:00
|
|
|
ncurses5
|
2019-11-04 14:53:02 +01: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 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
|
2022-05-28 13:15:48 +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;
|
|
|
|
};
|
2021-01-11 08:54:33 +01:00
|
|
|
meta = with lib; {
|
2018-09-02 18:41:20 +02: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 03:11:51 +02:00
|
|
|
then "https://developer.android.com/studio/index.html"
|
|
|
|
else "https://developer.android.com/studio/preview/index.html";
|
2020-04-12 17:23:46 +02: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 18:41:20 +02:00
|
|
|
platforms = [ "x86_64-linux" ];
|
2020-07-20 22:45:47 +02:00
|
|
|
maintainers = with maintainers; rec {
|
2024-04-27 20:51:42 +02:00
|
|
|
stable = [ alapshin ];
|
|
|
|
beta = [ alapshin ];
|
|
|
|
canary = [ alapshin ];
|
2020-07-20 22:45:47 +02:00
|
|
|
dev = canary;
|
|
|
|
}."${channel}";
|
2023-04-07 18:46:39 +02:00
|
|
|
mainProgram = pname;
|
2018-09-02 18:41:20 +02:00
|
|
|
};
|
|
|
|
}
|
|
|
|
''
|
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
|
|
|
|
2022-02-25 04:26:52 +01:00
|
|
|
ln -s ${androidStudio}/bin/studio.png $out/share/pixmaps/${pname}.png
|
2018-09-02 18:41:20 +02:00
|
|
|
ln -s ${desktopItem}/share/applications $out/share/applications
|
|
|
|
''
|