From 3a635da857bbbbaf0714e9483c7e3f8ef4c99653 Mon Sep 17 00:00:00 2001 From: hyperfekt Date: Thu, 5 Sep 2019 23:23:51 +0200 Subject: [PATCH] minecraft: 2015-07-24 -> 2.1.5965 switched to the new official launcher, renamed to minecraft-launcher, and added an update script --- pkgs/games/minecraft/default.nix | 142 +++++++++++++++++++++++++------ pkgs/games/minecraft/update.sh | 7 ++ 2 files changed, 121 insertions(+), 28 deletions(-) create mode 100755 pkgs/games/minecraft/update.sh diff --git a/pkgs/games/minecraft/default.nix b/pkgs/games/minecraft/default.nix index 32830d6f3d06..7abd6c162e0a 100644 --- a/pkgs/games/minecraft/default.nix +++ b/pkgs/games/minecraft/default.nix @@ -1,51 +1,137 @@ -{ stdenv, fetchurl, makeDesktopItem, makeWrapper -, jdk, jre, libpulseaudio, libXxf86vm +{ stdenv +, fetchurl +, makeDesktopItem +, makeWrapper +, jre # old or modded versions of the game may require Java 8 (https://aur.archlinux.org/packages/minecraft-launcher/#pinned-674960) +, xorg +, zlib +, nss +, nspr +, fontconfig +, gnome2 +, cairo +, expat +, alsaLib +, cups +, dbus +, atk +, gtk2-x11 +, gdk-pixbuf +, glib +, curl +, freetype +, libpulseaudio +, systemd +, flite ? null +, libXxf86vm ? null }: let desktopItem = makeDesktopItem { - name = "minecraft"; - exec = "minecraft"; - icon = "minecraft"; - comment = "A sandbox-building game"; - desktopName = "Minecraft"; - genericName = "minecraft"; - categories = "Game;"; + name = "minecraft-launcher"; + exec = "minecraft-launcher"; + icon = "minecraft-launcher"; + comment = "Official launcher for Minecraft, a sandbox-building game"; + desktopName = "Minecraft Launcher"; + categories = "Game;Application;"; }; - libPath = stdenv.lib.makeLibraryPath [ - libpulseaudio - libXxf86vm # Needed only for versions <1.13 - ]; + envLibPath = stdenv.lib.makeLibraryPath [ + curl + libpulseaudio + systemd + alsaLib # needed for narrator + flite # needed for narrator + libXxf86vm # needed only for versions <1.13 + ]; -in stdenv.mkDerivation { - name = "minecraft-2015-07-24"; + libPath = stdenv.lib.makeLibraryPath ([ + alsaLib + atk + cairo + cups + dbus + expat + fontconfig + freetype + gdk-pixbuf + glib + gnome2.GConf + gnome2.pango + gtk2-x11 + nspr + nss + stdenv.cc.cc + zlib + ] ++ + (with xorg; [ + libX11 + libxcb + libXcomposite + libXcursor + libXdamage + libXext + libXfixes + libXi + libXrandr + libXrender + libXtst + libXScrnSaver + ])); +in + stdenv.mkDerivation rec { + pname = "minecraft-launcher"; + + version = "2.1.5965"; src = fetchurl { - url = "https://s3.amazonaws.com/Minecraft.Download/launcher/Minecraft.jar"; - sha256 = "04pj4l5q0a64jncm2kk45r7nxnxa2z9n110dcxbbahdi6wk0png8"; + url = "https://launcher.mojang.com/download/linux/x86_64/minecraft-launcher_${version}.tar.gz"; + sha256 = "0wlc49s541li4cbxdmlw8fp34hp1q9m6ngr7l5hfdhv1i13s5845"; + }; + + icon = fetchurl { + url = "https://launcher.mojang.com/download/minecraft-launcher.svg"; + sha256 = "0w8z21ml79kblv20wh5lz037g130pxkgs8ll9s3bi94zn2pbrhim"; }; nativeBuildInputs = [ makeWrapper ]; - unpackPhase = "${jdk}/bin/jar xf $src favicon.png"; + sourceRoot = "."; + + dontConfigure = true; + dontBuild = true; installPhase = '' - mkdir -p $out/bin $out/share/minecraft + mkdir -p $out/opt + mv minecraft-launcher $out/opt - makeWrapper ${jre}/bin/java $out/bin/minecraft \ - --add-flags "-jar $out/share/minecraft/minecraft.jar" \ - --suffix LD_LIBRARY_PATH : ${libPath} + ${desktopItem.buildCommand} + install -D $icon $out/share/icons/hicolor/symbolic/apps/minecraft-launcher.svg - cp $src $out/share/minecraft/minecraft.jar - cp -r ${desktopItem}/share/applications $out/share - install -D favicon.png $out/share/icons/hicolor/32x32/apps/minecraft.png + makeWrapper $out/opt/minecraft-launcher/minecraft-launcher $out/bin/minecraft-launcher \ + --prefix LD_LIBRARY_PATH : ${envLibPath} \ + --prefix PATH : ${stdenv.lib.makeBinPath [ jre ]} + ''; + + preFixup = '' + patchelf \ + --set-interpreter ${stdenv.cc.bintools.dynamicLinker} \ + --set-rpath '$ORIGIN/'":${libPath}" \ + $out/opt/minecraft-launcher/minecraft-launcher + patchelf \ + --set-rpath '$ORIGIN/'":${libPath}" \ + $out/opt/minecraft-launcher/libcef.so + patchelf \ + --set-rpath '$ORIGIN/'":${libPath}" \ + $out/opt/minecraft-launcher/liblauncher.so ''; meta = with stdenv.lib; { - description = "A sandbox-building game"; - homepage = https://minecraft.net; + description = "Official launcher for Minecraft, a sandbox-building game"; + homepage = "https://minecraft.net"; maintainers = with maintainers; [ cpages ryantm infinisil ]; - license = licenses.unfreeRedistributable; + license = licenses.unfree; }; + + passthru.updateScript = ./update.sh; } diff --git a/pkgs/games/minecraft/update.sh b/pkgs/games/minecraft/update.sh new file mode 100755 index 000000000000..02b362e839be --- /dev/null +++ b/pkgs/games/minecraft/update.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env nix-shell +#!nix-shell -i bash -p curl jq gnugrep common-updater-scripts + +set -eu -o pipefail + +version=$(curl -s 'https://aur.archlinux.org/rpc/?v=5&type=info&arg[]=minecraft-launcher' | jq '.results[0].Version' | grep -Po '[.\d]*(?=-)') +update-source-version minecraft "$version"