diff options
Diffstat (limited to 'nixpkgs/pkgs/applications/editors/android-studio')
-rw-r--r-- | nixpkgs/pkgs/applications/editors/android-studio/common.nix | 169 | ||||
-rw-r--r-- | nixpkgs/pkgs/applications/editors/android-studio/default.nix | 43 |
2 files changed, 212 insertions, 0 deletions
diff --git a/nixpkgs/pkgs/applications/editors/android-studio/common.nix b/nixpkgs/pkgs/applications/editors/android-studio/common.nix new file mode 100644 index 000000000000..0d406ad2d360 --- /dev/null +++ b/nixpkgs/pkgs/applications/editors/android-studio/common.nix @@ -0,0 +1,169 @@ +{ channel, pname, version, build, sha256Hash }: + +{ bash +, buildFHSUserEnv +, coreutils +, fetchurl +, findutils +, file +, fontsConf +, git +, glxinfo +, gnugrep +, gnused +, gnutar +, gtk2, gnome_vfs, glib, GConf +, gzip +, fontconfig +, freetype +, libpulseaudio +, libGL +, libX11 +, libXext +, libXi +, libXrandr +, libXrender +, libXtst +, makeWrapper +, pciutils +, pkgsi686Linux +, setxkbmap +, stdenv +, unzip +, which +, runCommand +, xkeyboard_config +, zlib +, makeDesktopItem +}: + +let + drvName = "android-studio-${channel}-${version}"; + androidStudio = stdenv.mkDerivation { + name = "${drvName}-unwrapped"; + + src = fetchurl { + url = "https://dl.google.com/dl/android/studio/ide-zips/${version}/android-studio-ide-${build}-linux.tar.gz"; + sha256 = sha256Hash; + }; + + buildInputs = [ + makeWrapper + unzip + ]; + installPhase = '' + cp -r . $out + wrapProgram $out/bin/studio.sh \ + --set ANDROID_EMULATOR_USE_SYSTEM_LIBS 1 \ + --prefix PATH : "${stdenv.lib.makeBinPath [ + + # Checked in studio.sh + coreutils + findutils + gnugrep + which + gnused + + # For Android emulator + file + glxinfo + pciutils + setxkbmap + + # Used during setup wizard + gnutar + gzip + + # Runtime stuff + git + ]}" \ + --prefix LD_LIBRARY_PATH : "${stdenv.lib.makeLibraryPath [ + + # Crash at startup without these + fontconfig + freetype + libXext + libXi + libXrender + libXtst + + # 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 + pkgsi686Linux.zlib + # Support multiple monitors + libXrandr + + # For Android emulator + libpulseaudio + libX11 + libGL + + # For GTKLookAndFeel + gtk2 + gnome_vfs + glib + GConf + ]}" \ + --set QT_XKB_CONFIG_ROOT "${xkeyboard_config}/share/X11/xkb" \ + --set FONTCONFIG_FILE ${fontsConf} + ''; + }; + + 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 + # (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 = "${drvName}-fhs-env"; + multiPkgs = pkgs: [ pkgs.ncurses5 ]; + }; +in runCommand + drvName + { + startScript = '' + #!${bash}/bin/bash + ${fhsEnv}/bin/${drvName}-fhs-env ${androidStudio}/bin/studio.sh + ''; + preferLocalBuild = true; + allowSubstitutes = false; + passthru = { + unwrapped = androidStudio; + }; + 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} + + 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 + '' diff --git a/nixpkgs/pkgs/applications/editors/android-studio/default.nix b/nixpkgs/pkgs/applications/editors/android-studio/default.nix new file mode 100644 index 000000000000..b5381983240a --- /dev/null +++ b/nixpkgs/pkgs/applications/editors/android-studio/default.nix @@ -0,0 +1,43 @@ +{ callPackage, makeFontsConf, gnome2 }: + +let + mkStudio = opts: callPackage (import ./common.nix opts) { + fontsConf = makeFontsConf { + fontDirectories = []; + }; + inherit (gnome2) GConf gnome_vfs; + }; + stableVersion = { + version = "3.5.0.21"; # "Android Studio 3.5" + build = "191.5791312"; + sha256Hash = "0vvk2vhklxg9wfi4lv4sahs5ahhb1mki1msy3yixmr56vipgv52p"; + }; + betaVersion = stableVersion; + latestVersion = { # canary & dev + version = "3.6.0.10"; # "Android Studio 3.6 Canary 10" + build = "192.5842447"; + sha256Hash = "0qyvqm0ihp6czx77skia87qnz87wrsp1a6la04dr4b0xln2c8m5b"; + }; +in { + # Attributes are named by their corresponding release channels + + stable = mkStudio (stableVersion // { + channel = "stable"; + pname = "android-studio"; + }); + + beta = mkStudio (betaVersion // { + channel = "beta"; + pname = "android-studio-beta"; + }); + + dev = mkStudio (latestVersion // { + channel = "dev"; + pname = "android-studio-dev"; + }); + + canary = mkStudio (latestVersion // { + channel = "canary"; + pname = "android-studio-canary"; + }); +} |