git.iko.soy/typeable/nixpkgs
on master help sign in
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.

commitf822b93e0558441962ac7f18b2f39848ca75f154 authorHoang Xuan Phu <phuhimself@phunehehe.net> dateThu 7 Jul 2016, 20:25 (10 years ago) parent9c38161
3 files changed+95−41
pkgs/applications/editors/android-studio/default.nix+82 pkgs/applications/editors/idea/default.nix−41 pkgs/top-level/all-packages.nix+13
pkgs/applications/editors/android-studio/default.nixnew file+82
@@ -0,0 +1,82 @@
1+{ bash
2+, buildFHSUserEnv
3+, coreutils
4+, fetchurl
5+, findutils
6+, git
7+, gnugrep
8+, gnutar
9+, gzip
10+, jdk
11+, libXrandr
12+, makeWrapper
13+, pkgsi686Linux
14+, stdenv
15+, unzip
16+, which
17+, writeTextFile
18+, zlib
19+}:
20+
21+let
22+
23+ version = "2.1.2.0";
24+ build = "143.2915827";
25+
26+ androidStudio = stdenv.mkDerivation {
27+ name = "android-studio";
28+ buildInputs = [
29+ makeWrapper
30+ unzip
31+ ];
32+ installPhase = ''
33+ cp -r . $out
34+ wrapProgram $out/bin/studio.sh --set PATH "${stdenv.lib.makeBinPath [
35+
36+ # Checked in studio.sh
37+ coreutils
38+ findutils
39+ gnugrep
40+ jdk
41+ which
42+
43+ # Used during setup wizard
44+ gnutar
45+ gzip
46+
47+ # Runtime stuff
48+ git
49+
50+ ]}" --set LD_LIBRARY_PATH "${stdenv.lib.makeLibraryPath [
51+ # Gradle wants libstdc++.so.6
52+ stdenv.cc.cc.lib
53+ # mksdcard wants 32 bit libstdc++.so.6
54+ pkgsi686Linux.stdenv.cc.cc.lib
55+ # aapt wants libz.so.1
56+ zlib
57+ # Support multiple monitors
58+ libXrandr
59+ ]}"
60+ '';
61+ src = fetchurl {
62+ url = "https://dl.google.com/dl/android/studio/ide-zips/${version}/android-studio-ide-${build}-linux.zip";
63+ sha256 = "0q61m8yln77valg7y6lyxlml53z387zh6fyfgc22sm3br5ahbams";
64+ };
65+ };
66+
67+ # Android Studio downloads prebuilt binaries as part of the SDK. These tools
68+ # (e.g. `mksdcard`) have `/lib/ld-linux.so.2` set as the interpreter. An FHS
69+ # environment is used as a work around for that.
70+ fhsEnv = buildFHSUserEnv {
71+ name = "android-studio-fhs-env";
72+ };
73+
74+in writeTextFile {
75+ name = "android-studio-${version}";
76+ destination = "/bin/android-studio";
77+ executable = true;
78+ text = ''
79+ #!${bash}/bin/bash
80+ ${fhsEnv}/bin/android-studio-fhs-env ${androidStudio}/bin/studio.sh
81+ '';
82+}
pkgs/applications/editors/idea/default.nix−41
@@ -10,33 +10,6 @@ let
1010 bnumber = with stdenv.lib; build: last (splitString "-" build);
1111 mkIdeaProduct = callPackage ./common.nix { };
1212
13− buildAndroidStudio = { name, version, build, src, license, description, wmClass }:
14− let drv = (mkIdeaProduct rec {
15− inherit name version build src wmClass jdk;
16− product = "Studio";
17− meta = with stdenv.lib; {
18− homepage = https://developer.android.com/sdk/installing/studio.html;
19− inherit description license;
20− longDescription = ''
21− Android development environment based on IntelliJ
22− IDEA providing new features and improvements over
23− Eclipse ADT and will be the official Android IDE
24− once it's ready.
25− '';
26− platforms = platforms.linux;
27− hydraPlatforms = []; # Depends on androidsdk, which hits Hydra's output limits
28− maintainers = with maintainers; [ edwtjo ];
29− };
30− });
31− in stdenv.lib.overrideDerivation drv (x : {
32− buildInputs = x.buildInputs ++ [ makeWrapper ];
33− installPhase = x.installPhase + ''
34− wrapProgram "$out/bin/android-studio" \
35− --set ANDROID_HOME "${androidsdk}/libexec/" \
36− --set LD_LIBRARY_PATH "${stdenv.cc.cc.lib}/lib" # Gradle installs libnative-platform.so in ~/.gradle, that requires libstdc++.so.6
37− '';
38− });
39−
4013 buildClion = { name, version, build, src, license, description, wmClass }:
4114 (mkIdeaProduct rec {
4215 inherit name version build src wmClass jdk;
@@ -148,20 +121,6 @@ in
148121
149122{
150123
151− android-studio = let buildNumber = "143.2915827"; in buildAndroidStudio rec {
152− name = "android-studio-${version}";
153− version = "2.1.2.0";
154− build = "AI-${buildNumber}";
155− description = "Android development environment based on IntelliJ IDEA";
156− license = stdenv.lib.licenses.asl20;
157− src = fetchurl {
158− url = "https://dl.google.com/dl/android/studio/ide-zips/${version}" +
159− "/android-studio-ide-${buildNumber}-linux.zip";
160− sha256 = "0q61m8yln77valg7y6lyxlml53z387zh6fyfgc22sm3br5ahbams";
161− };
162− wmClass = "jetbrains-studio";
163− };
164−
165124 clion = buildClion rec {
166125 name = "clion-${version}";
167126 version = "1.2.5";
pkgs/top-level/all-packages.nix+13
@@ -12263,6 +12263,19 @@ in
1226312263
1226412264 amsn = callPackage ../applications/networking/instant-messengers/amsn { };
1226512265
12266+ # Oracle JDK is recommended upstream, but unfree and requires a manual
12267+ # download. OpenJDK is straightforward, but may suffer from compatibility
12268+ # problems e.g. https://code.google.com/p/android/issues/detail?id=174496.
12269+ # To use Oracle JDK add an override to ~/.nixpkgs/config.nix:
12270+ # {
12271+ # packageOverrides = pkgs: {
12272+ # android-studio = pkgs.android-studio.override {
12273+ # jdk = pkgs.oraclejdk8;
12274+ # };
12275+ # };
12276+ # }
12277+ android-studio = callPackage ../applications/editors/android-studio { };
12278+
1226612279 antimony = qt5.callPackage ../applications/graphics/antimony {};
1226712280
1226812281 antiword = callPackage ../applications/office/antiword {};