android-studio: Refactor the code & minor improvements

+39 -45
+39 -45
pkgs/applications/editors/android-studio/common.nix
··· 31 31 , stdenv 32 32 , unzip 33 33 , which 34 - , writeTextFile 34 + , runCommand 35 35 , xkeyboard_config 36 36 , zlib 37 37 , makeDesktopItem ··· 39 39 40 40 let 41 41 drvName = "android-studio-${channel}-${version}"; 42 - androidStudio = stdenv.mkDerivation rec { 42 + androidStudio = stdenv.mkDerivation { 43 43 name = drvName; 44 44 45 45 src = fetchurl { ··· 111 111 ]}" \ 112 112 --set QT_XKB_CONFIG_ROOT "${xkeyboard_config}/share/X11/xkb" \ 113 113 --set FONTCONFIG_FILE ${fontsConf} 114 - 115 - install -Dm644 bin/studio.png $out/share/pixmaps/${drvName}.png 116 - ln -s ${desktopItem}/share/applications $out/share/applications 117 114 ''; 118 - 119 - desktopItem = makeDesktopItem rec { 120 - name = drvName; 121 - exec = pname; 122 - icon = drvName; 123 - desktopName = "Android Studio"; 124 - comment = "The official Android IDE"; 125 - categories = "Development;IDE;"; 126 - }; 115 + }; 127 116 117 + desktopItem = makeDesktopItem { 118 + name = drvName; 119 + exec = pname; 120 + icon = drvName; 121 + desktopName = "Android Studio (${channel} channel)"; 122 + comment = "The official Android IDE"; 123 + categories = "Development;IDE;"; 124 + startupNotify = "true"; 125 + extraEntries="StartupWMClass=jetbrains-studio"; 128 126 }; 129 127 130 128 # Android Studio downloads prebuilt binaries as part of the SDK. These tools ··· 134 132 name = "${drvName}-fhs-env"; 135 133 multiPkgs = pkgs: [ pkgs.ncurses5 ]; 136 134 }; 137 - 138 - wrapper = writeTextFile { 139 - name = "${drvName}-wrapper"; 140 - # TODO: Rename preview -> beta (and add -stable suffix?): 141 - destination = "/bin/${pname}"; 142 - executable = true; 143 - text = '' 135 + in runCommand 136 + "${drvName}-wrapper" 137 + { 138 + startScript = '' 144 139 #!${bash}/bin/bash 145 140 ${fhsEnv}/bin/${drvName}-fhs-env ${androidStudio}/bin/studio.sh 146 141 ''; 147 - }; 148 - in stdenv.mkDerivation { 149 - name = "${drvName}-with-desktop-item"; 150 - 151 - buildCommand = '' 142 + preferLocalBuild = true; 143 + allowSubstitutes = false; 144 + meta = with stdenv.lib; { 145 + description = "The Official IDE for Android (${channel} channel)"; 146 + longDescription = '' 147 + Android Studio is the official IDE for Android app development, based on 148 + IntelliJ IDEA. 149 + ''; 150 + homepage = if channel == "stable" 151 + then https://developer.android.com/studio/index.html 152 + else https://developer.android.com/studio/preview/index.html; 153 + license = licenses.asl20; 154 + platforms = [ "x86_64-linux" ]; 155 + maintainers = with maintainers; [ primeos ]; 156 + }; 157 + } 158 + '' 152 159 mkdir -p $out/{bin,share/pixmaps} 153 - ln -s ${wrapper}/bin/${pname} $out/bin/${pname} 154 - 155 - ln -s ${androidStudio}/share/pixmaps/${drvName}.png $out/share/pixmaps/${drvName}.png 156 - ln -s ${androidStudio}/share/applications $out/share/applications 157 - ''; 158 160 159 - meta = with stdenv.lib; { 160 - description = "The Official IDE for Android (${channel} channel)"; 161 - longDescription = '' 162 - Android Studio is the official IDE for Android app development, based on 163 - IntelliJ IDEA. 164 - ''; 165 - homepage = if channel == "stable" 166 - then https://developer.android.com/studio/index.html 167 - else https://developer.android.com/studio/preview/index.html; 168 - license = licenses.asl20; 169 - platforms = [ "x86_64-linux" ]; 170 - maintainers = with maintainers; [ primeos ]; 171 - }; 172 - } 161 + # TODO: Rename preview -> beta (and add -stable suffix?): 162 + echo -n "$startScript" > $out/bin/${pname} 163 + chmod +x $out/bin/${pname} 164 + ln -s ${androidStudio}/bin/studio.png $out/share/pixmaps/${drvName}.png 165 + ln -s ${desktopItem}/share/applications $out/share/applications 166 + ''