summary refs log tree commit diff
path: root/pkgs/applications
diff options
context:
space:
mode:
authorMichael Weiss <dev.primeos@gmail.com>2018-09-02 18:41:20 +0200
committerMichael Weiss <dev.primeos@gmail.com>2018-09-02 18:45:40 +0200
commit85e46d12b33c848cb01a0d6563394ea07ac3d33f (patch)
tree5ce16093f522eb36d96f11599e85a73c3a5a772a /pkgs/applications
parent1ee3ad6732dd617806d333bc3a0370fadf62f69f (diff)
downloadnixlib-85e46d12b33c848cb01a0d6563394ea07ac3d33f.tar
nixlib-85e46d12b33c848cb01a0d6563394ea07ac3d33f.tar.gz
nixlib-85e46d12b33c848cb01a0d6563394ea07ac3d33f.tar.bz2
nixlib-85e46d12b33c848cb01a0d6563394ea07ac3d33f.tar.lz
nixlib-85e46d12b33c848cb01a0d6563394ea07ac3d33f.tar.xz
nixlib-85e46d12b33c848cb01a0d6563394ea07ac3d33f.tar.zst
nixlib-85e46d12b33c848cb01a0d6563394ea07ac3d33f.zip
android-studio: Refactor the code & minor improvements
Diffstat (limited to 'pkgs/applications')
-rw-r--r--pkgs/applications/editors/android-studio/common.nix84
1 files changed, 39 insertions, 45 deletions
diff --git a/pkgs/applications/editors/android-studio/common.nix b/pkgs/applications/editors/android-studio/common.nix
index 1d49c8c74a9a..23e0584cb7f0 100644
--- a/pkgs/applications/editors/android-studio/common.nix
+++ b/pkgs/applications/editors/android-studio/common.nix
@@ -31,7 +31,7 @@
 , stdenv
 , unzip
 , which
-, writeTextFile
+, runCommand
 , xkeyboard_config
 , zlib
 , makeDesktopItem
@@ -39,7 +39,7 @@
 
 let
   drvName = "android-studio-${channel}-${version}";
-  androidStudio = stdenv.mkDerivation rec {
+  androidStudio = stdenv.mkDerivation {
     name = drvName;
 
     src = fetchurl {
@@ -111,20 +111,18 @@ let
         ]}" \
         --set QT_XKB_CONFIG_ROOT "${xkeyboard_config}/share/X11/xkb" \
         --set FONTCONFIG_FILE ${fontsConf}
-
-        install -Dm644 bin/studio.png $out/share/pixmaps/${drvName}.png
-        ln -s ${desktopItem}/share/applications $out/share/applications
     '';
+  };
 
-    desktopItem = makeDesktopItem rec {
-      name = drvName;
-      exec = pname;
-      icon = drvName;
-      desktopName = "Android Studio";
-      comment = "The official Android IDE";
-      categories = "Development;IDE;";
-    };
-
+  desktopItem = makeDesktopItem {
+    name = drvName;
+    exec = pname;
+    icon = drvName;
+    desktopName = "Android Studio (${channel} channel)";
+    comment = "The official Android IDE";
+    categories = "Development;IDE;";
+    startupNotify = "true";
+    extraEntries="StartupWMClass=jetbrains-studio";
   };
 
   # Android Studio downloads prebuilt binaries as part of the SDK. These tools
@@ -134,39 +132,35 @@ let
     name = "${drvName}-fhs-env";
     multiPkgs = pkgs: [ pkgs.ncurses5 ];
   };
-
-  wrapper = writeTextFile {
-    name = "${drvName}-wrapper";
-    # TODO: Rename preview -> beta (and add -stable suffix?):
-    destination = "/bin/${pname}";
-    executable = true;
-    text = ''
+in runCommand
+  "${drvName}-wrapper"
+  {
+    startScript = ''
       #!${bash}/bin/bash
       ${fhsEnv}/bin/${drvName}-fhs-env ${androidStudio}/bin/studio.sh
     '';
-  };
-in stdenv.mkDerivation {
-  name = "${drvName}-with-desktop-item";
-
-  buildCommand = ''
+    preferLocalBuild = true;
+    allowSubstitutes = false;
+    meta = with stdenv.lib; {
+      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"
+        then https://developer.android.com/studio/index.html
+        else https://developer.android.com/studio/preview/index.html;
+      license = licenses.asl20;
+      platforms = [ "x86_64-linux" ];
+      maintainers = with maintainers; [ primeos ];
+    };
+  }
+  ''
     mkdir -p $out/{bin,share/pixmaps}
-    ln -s ${wrapper}/bin/${pname} $out/bin/${pname}
-
-    ln -s ${androidStudio}/share/pixmaps/${drvName}.png $out/share/pixmaps/${drvName}.png
-    ln -s ${androidStudio}/share/applications $out/share/applications
-  '';
 
-  meta = with stdenv.lib; {
-    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"
-      then https://developer.android.com/studio/index.html
-      else https://developer.android.com/studio/preview/index.html;
-    license = licenses.asl20;
-    platforms = [ "x86_64-linux" ];
-    maintainers = with maintainers; [ primeos ];
-  };
-}
+    # TODO: Rename preview -> beta (and add -stable suffix?):
+    echo -n "$startScript" > $out/bin/${pname}
+    chmod +x $out/bin/${pname}
+    ln -s ${androidStudio}/bin/studio.png $out/share/pixmaps/${drvName}.png
+    ln -s ${desktopItem}/share/applications $out/share/applications
+  ''