android-studio: repackage in an FHS environment
This commit fixes 2 main problems: - Android Studio comes with its own package manager. The current packaging approach doesn't allow such management. As a result the package is unusable (see https://github.com/NixOS/nixpkgs/issues/8650 and https://github.com/NixOS/nixpkgs/issues/14903). In this version, $ANDROID_HOME is _not_ set, allowing Android Studio to deal with the Android SDK as it pleases (typically in $HOME/Android/Sdk). - 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.
This commit is contained in:
parent
9c381612ba
commit
f822b93e05
82
pkgs/applications/editors/android-studio/default.nix
Normal file
82
pkgs/applications/editors/android-studio/default.nix
Normal file
@ -0,0 +1,82 @@
|
||||
{ bash
|
||||
, buildFHSUserEnv
|
||||
, coreutils
|
||||
, fetchurl
|
||||
, findutils
|
||||
, git
|
||||
, gnugrep
|
||||
, gnutar
|
||||
, gzip
|
||||
, jdk
|
||||
, libXrandr
|
||||
, makeWrapper
|
||||
, pkgsi686Linux
|
||||
, stdenv
|
||||
, unzip
|
||||
, which
|
||||
, writeTextFile
|
||||
, zlib
|
||||
}:
|
||||
|
||||
let
|
||||
|
||||
version = "2.1.2.0";
|
||||
build = "143.2915827";
|
||||
|
||||
androidStudio = stdenv.mkDerivation {
|
||||
name = "android-studio";
|
||||
buildInputs = [
|
||||
makeWrapper
|
||||
unzip
|
||||
];
|
||||
installPhase = ''
|
||||
cp -r . $out
|
||||
wrapProgram $out/bin/studio.sh --set PATH "${stdenv.lib.makeBinPath [
|
||||
|
||||
# Checked in studio.sh
|
||||
coreutils
|
||||
findutils
|
||||
gnugrep
|
||||
jdk
|
||||
which
|
||||
|
||||
# Used during setup wizard
|
||||
gnutar
|
||||
gzip
|
||||
|
||||
# Runtime stuff
|
||||
git
|
||||
|
||||
]}" --set LD_LIBRARY_PATH "${stdenv.lib.makeLibraryPath [
|
||||
# Gradle wants libstdc++.so.6
|
||||
stdenv.cc.cc.lib
|
||||
# mksdcard wants 32 bit libstdc++.so.6
|
||||
pkgsi686Linux.stdenv.cc.cc.lib
|
||||
# aapt wants libz.so.1
|
||||
zlib
|
||||
# Support multiple monitors
|
||||
libXrandr
|
||||
]}"
|
||||
'';
|
||||
src = fetchurl {
|
||||
url = "https://dl.google.com/dl/android/studio/ide-zips/${version}/android-studio-ide-${build}-linux.zip";
|
||||
sha256 = "0q61m8yln77valg7y6lyxlml53z387zh6fyfgc22sm3br5ahbams";
|
||||
};
|
||||
};
|
||||
|
||||
# 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 {
|
||||
name = "android-studio-fhs-env";
|
||||
};
|
||||
|
||||
in writeTextFile {
|
||||
name = "android-studio-${version}";
|
||||
destination = "/bin/android-studio";
|
||||
executable = true;
|
||||
text = ''
|
||||
#!${bash}/bin/bash
|
||||
${fhsEnv}/bin/android-studio-fhs-env ${androidStudio}/bin/studio.sh
|
||||
'';
|
||||
}
|
@ -10,33 +10,6 @@ let
|
||||
bnumber = with stdenv.lib; build: last (splitString "-" build);
|
||||
mkIdeaProduct = callPackage ./common.nix { };
|
||||
|
||||
buildAndroidStudio = { name, version, build, src, license, description, wmClass }:
|
||||
let drv = (mkIdeaProduct rec {
|
||||
inherit name version build src wmClass jdk;
|
||||
product = "Studio";
|
||||
meta = with stdenv.lib; {
|
||||
homepage = https://developer.android.com/sdk/installing/studio.html;
|
||||
inherit description license;
|
||||
longDescription = ''
|
||||
Android development environment based on IntelliJ
|
||||
IDEA providing new features and improvements over
|
||||
Eclipse ADT and will be the official Android IDE
|
||||
once it's ready.
|
||||
'';
|
||||
platforms = platforms.linux;
|
||||
hydraPlatforms = []; # Depends on androidsdk, which hits Hydra's output limits
|
||||
maintainers = with maintainers; [ edwtjo ];
|
||||
};
|
||||
});
|
||||
in stdenv.lib.overrideDerivation drv (x : {
|
||||
buildInputs = x.buildInputs ++ [ makeWrapper ];
|
||||
installPhase = x.installPhase + ''
|
||||
wrapProgram "$out/bin/android-studio" \
|
||||
--set ANDROID_HOME "${androidsdk}/libexec/" \
|
||||
--set LD_LIBRARY_PATH "${stdenv.cc.cc.lib}/lib" # Gradle installs libnative-platform.so in ~/.gradle, that requires libstdc++.so.6
|
||||
'';
|
||||
});
|
||||
|
||||
buildClion = { name, version, build, src, license, description, wmClass }:
|
||||
(mkIdeaProduct rec {
|
||||
inherit name version build src wmClass jdk;
|
||||
@ -148,20 +121,6 @@ in
|
||||
|
||||
{
|
||||
|
||||
android-studio = let buildNumber = "143.2915827"; in buildAndroidStudio rec {
|
||||
name = "android-studio-${version}";
|
||||
version = "2.1.2.0";
|
||||
build = "AI-${buildNumber}";
|
||||
description = "Android development environment based on IntelliJ IDEA";
|
||||
license = stdenv.lib.licenses.asl20;
|
||||
src = fetchurl {
|
||||
url = "https://dl.google.com/dl/android/studio/ide-zips/${version}" +
|
||||
"/android-studio-ide-${buildNumber}-linux.zip";
|
||||
sha256 = "0q61m8yln77valg7y6lyxlml53z387zh6fyfgc22sm3br5ahbams";
|
||||
};
|
||||
wmClass = "jetbrains-studio";
|
||||
};
|
||||
|
||||
clion = buildClion rec {
|
||||
name = "clion-${version}";
|
||||
version = "1.2.5";
|
||||
|
@ -12263,6 +12263,19 @@ in
|
||||
|
||||
amsn = callPackage ../applications/networking/instant-messengers/amsn { };
|
||||
|
||||
# Oracle JDK is recommended upstream, but unfree and requires a manual
|
||||
# download. OpenJDK is straightforward, but may suffer from compatibility
|
||||
# problems e.g. https://code.google.com/p/android/issues/detail?id=174496.
|
||||
# To use Oracle JDK add an override to ~/.nixpkgs/config.nix:
|
||||
# {
|
||||
# packageOverrides = pkgs: {
|
||||
# android-studio = pkgs.android-studio.override {
|
||||
# jdk = pkgs.oraclejdk8;
|
||||
# };
|
||||
# };
|
||||
# }
|
||||
android-studio = callPackage ../applications/editors/android-studio { };
|
||||
|
||||
antimony = qt5.callPackage ../applications/graphics/antimony {};
|
||||
|
||||
antiword = callPackage ../applications/office/antiword {};
|
||||
|
Loading…
Reference in New Issue
Block a user