summary refs log tree commit diff
diff options
context:
space:
mode:
authorRobin Gloster <mail@glob.in>2016-08-11 17:10:01 +0000
committerGitHub <noreply@github.com>2016-08-11 17:10:01 +0000
commitcfdab94bb3d90edc3fd226a44eb1476c42d8d98a (patch)
tree491a892e29cf0e0ca144e6a5ec859b97bf66f481
parentbb4884bb3205e36d9ff67be33638728fd6c6fccc (diff)
parentf822b93e0558441962ac7f18b2f39848ca75f154 (diff)
downloadnixpkgs-cfdab94bb3d90edc3fd226a44eb1476c42d8d98a.tar
nixpkgs-cfdab94bb3d90edc3fd226a44eb1476c42d8d98a.tar.gz
nixpkgs-cfdab94bb3d90edc3fd226a44eb1476c42d8d98a.tar.bz2
nixpkgs-cfdab94bb3d90edc3fd226a44eb1476c42d8d98a.tar.lz
nixpkgs-cfdab94bb3d90edc3fd226a44eb1476c42d8d98a.tar.xz
nixpkgs-cfdab94bb3d90edc3fd226a44eb1476c42d8d98a.tar.zst
nixpkgs-cfdab94bb3d90edc3fd226a44eb1476c42d8d98a.zip
Merge pull request #16752 from phunehehe/android-studio
android-studio: repackage in an FHS environment
-rw-r--r--pkgs/applications/editors/android-studio/default.nix82
-rw-r--r--pkgs/applications/editors/idea/default.nix41
-rw-r--r--pkgs/top-level/all-packages.nix13
3 files changed, 95 insertions, 41 deletions
diff --git a/pkgs/applications/editors/android-studio/default.nix b/pkgs/applications/editors/android-studio/default.nix
new file mode 100644
index 00000000000..eea686d691d
--- /dev/null
+++ b/pkgs/applications/editors/android-studio/default.nix
@@ -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
+  '';
+}
diff --git a/pkgs/applications/editors/idea/default.nix b/pkgs/applications/editors/idea/default.nix
index 7bfa55d28bd..c113b63390f 100644
--- a/pkgs/applications/editors/idea/default.nix
+++ b/pkgs/applications/editors/idea/default.nix
@@ -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";
diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix
index bff291181fb..b79c331d812 100644
--- a/pkgs/top-level/all-packages.nix
+++ b/pkgs/top-level/all-packages.nix
@@ -12274,6 +12274,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 {};