android-studio: Refactor the code & minor improvements

This commit is contained in:
Michael Weiss 2018-09-02 18:41:20 +02:00
parent 1ee3ad6732
commit 85e46d12b3

View File

@ -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 {
desktopItem = makeDesktopItem {
name = drvName;
exec = pname;
icon = drvName;
desktopName = "Android Studio";
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,28 +132,15 @@ 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 = ''
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
'';
preferLocalBuild = true;
allowSubstitutes = false;
meta = with stdenv.lib; {
description = "The Official IDE for Android (${channel} channel)";
longDescription = ''
@ -170,3 +155,12 @@ in stdenv.mkDerivation {
maintainers = with maintainers; [ primeos ];
};
}
''
mkdir -p $out/{bin,share/pixmaps}
# 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
''