git.iko.soy/typeable/nixpkgs
on master help sign in
Merge pull request #16752 from phunehehe/android-studio

android-studio: repackage in an FHS environment

commitcfdab94bb3d90edc3fd226a44eb1476c42d8d98a authorRobin Gloster <mail@glob.in> dateThu 11 Aug 2016, 17:10 (10 years ago) parentbb4884bf822b93
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
@@ -12274,6 +12274,19 @@ in
1227412274
1227512275 amsn = callPackage ../applications/networking/instant-messengers/amsn { };
1227612276
12277+ # Oracle JDK is recommended upstream, but unfree and requires a manual
12278+ # download. OpenJDK is straightforward, but may suffer from compatibility
12279+ # problems e.g. https://code.google.com/p/android/issues/detail?id=174496.
12280+ # To use Oracle JDK add an override to ~/.nixpkgs/config.nix:
12281+ # {
12282+ # packageOverrides = pkgs: {
12283+ # android-studio = pkgs.android-studio.override {
12284+ # jdk = pkgs.oraclejdk8;
12285+ # };
12286+ # };
12287+ # }
12288+ android-studio = callPackage ../applications/editors/android-studio { };
12289+
1227712290 antimony = qt5.callPackage ../applications/graphics/antimony {};
1227812291
1227912292 antiword = callPackage ../applications/office/antiword {};