From 47f78cd36ae1acd85557b27e7e4b6e8eb8012bc2 Mon Sep 17 00:00:00 2001 From: Silvan Mosberger Date: Thu, 19 Jul 2018 00:05:53 +0200 Subject: [PATCH] minecraft: clean and fix up The launcher now downloads almost all required libraries itself into ~/.minecraft and there's nothing one can do about it. Sound only works with libpulseaudio though --- pkgs/games/minecraft/default.nix | 49 ++++++++++++-------------------- pkgs/top-level/all-packages.nix | 4 +-- 2 files changed, 19 insertions(+), 34 deletions(-) diff --git a/pkgs/games/minecraft/default.nix b/pkgs/games/minecraft/default.nix index e59181bb0fa0..76edc512b0eb 100644 --- a/pkgs/games/minecraft/default.nix +++ b/pkgs/games/minecraft/default.nix @@ -1,11 +1,6 @@ -{ stdenv, fetchurl, makeDesktopItem -, jre, libX11, libXext, libXcursor, libXrandr, libXxf86vm -, openjdk -, libGLU_combined, openal -, useAlsa ? false, alsaOss ? null }: -with stdenv.lib; - -assert useAlsa -> alsaOss != null; +{ stdenv, fetchurl, makeDesktopItem, makeWrapper +, jdk, jre, libpulseaudio +}: let desktopItem = makeDesktopItem { @@ -19,41 +14,33 @@ let }; in stdenv.mkDerivation { - name = "minecraft-2015.07.24"; + name = "minecraft-2015-07-24"; src = fetchurl { url = "https://s3.amazonaws.com/Minecraft.Download/launcher/Minecraft.jar"; sha256 = "04pj4l5q0a64jncm2kk45r7nxnxa2z9n110dcxbbahdi6wk0png8"; }; - phases = "installPhase"; + nativeBuildInputs = [ makeWrapper ]; + + unpackPhase = "${jdk}/bin/jar xf $src favicon.png"; installPhase = '' - set -x - mkdir -pv $out/bin - cp -v $src $out/minecraft.jar + mkdir -p $out/bin $out/share/minecraft - cat > $out/bin/minecraft << EOF - #!${stdenv.shell} + makeWrapper ${jre}/bin/java $out/bin/minecraft \ + --add-flags "-jar $out/share/minecraft/minecraft.jar" \ + --suffix LD_LIBRARY_PATH : ${stdenv.lib.makeLibraryPath [ libpulseaudio ]} - export LD_LIBRARY_PATH=\$LD_LIBRARY_PATH:${makeLibraryPath [ libX11 libXext libXcursor libXrandr libXxf86vm libGLU_combined openal ]} - ${if useAlsa then "${alsaOss}/bin/aoss" else "" } \ - ${jre}/bin/java -jar $out/minecraft.jar - EOF - - chmod +x $out/bin/minecraft - - mkdir -p $out/share/applications - ln -s ${desktopItem}/share/applications/* $out/share/applications/ - - ${openjdk}/bin/jar xf $out/minecraft.jar favicon.png + 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 ''; - meta = { - description = "A sandbox-building game"; - homepage = http://www.minecraft.net; - maintainers = with stdenv.lib.maintainers; [ cpages ryantm ]; - license = stdenv.lib.licenses.unfreeRedistributable; + meta = with stdenv.lib; { + description = "A sandbox-building game"; + homepage = https://minecraft.net; + maintainers = with maintainers; [ cpages ryantm infinisil ]; + license = licenses.unfreeRedistributable; }; } diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 5a5def85f406..814b6ad6c1ec 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -19661,9 +19661,7 @@ with pkgs; megaglest = callPackage ../games/megaglest {}; - minecraft = callPackage ../games/minecraft { - useAlsa = config.minecraft.alsa or false; - }; + minecraft = callPackage ../games/minecraft { }; minecraft-server = callPackage ../games/minecraft-server { };