From 26e02c1972fb05799289ff25801bcbaa535f72bf Mon Sep 17 00:00:00 2001 From: Sergei Trofimovich Date: Sat, 30 Apr 2022 14:19:13 +0100 Subject: [PATCH] mindustry: propagate more runtime depends glew alone is not enough to propagate explicitly: ``` $ nix run nixpkgs#mindustry [E] Failed to initialize discord. Enable debug logging for details. [E] java.lang.ExceptionInInitializerError at arc.backend.sdl.SdlApplication.lambda$init$0(SdlApplication.java:73) at arc.backend.sdl.SdlApplication.check(SdlApplication.java:181) at arc.backend.sdl.SdlApplication.init(SdlApplication.java:73) at arc.backend.sdl.SdlApplication.(SdlApplication.java:29) at mindustry.desktop.DesktopLauncher.main(DesktopLauncher.java:36) Caused by: arc.util.ArcRuntimeException: Couldn't load shared library 'libsdl-arc64.so' for target: Linux, 64-bit at arc.util.SharedLibraryLoader.load(SharedLibraryLoader.java:85) at arc.backend.sdl.jni.SDL.(SDL.java:142) ... 5 more Caused by: arc.util.ArcRuntimeException: java.lang.UnsatisfiedLinkError: /tmp/arc/35a2b27b/libsdl-arc64.so: /nix/store/v8pdm5rd4f89ng08zgxryyil065g1dh2-SDL2-2.0.20/lib/libSDL2.so: cannot open shared object file: No such file or directory at arc.util.SharedLibraryLoader.loadFile(SharedLibraryLoader.java:288) at arc.util.SharedLibraryLoader.load(SharedLibraryLoader.java:81) ... 6 more Caused by: java.lang.UnsatisfiedLinkError: /tmp/arc/35a2b27b/libsdl-arc64.so: /nix/store/v8pdm5rd4f89ng08zgxryyil065g1dh2-SDL2-2.0.20/lib/libSDL2.so: cannot open shared object file: No such file or directory at java.base/jdk.internal.loader.NativeLibraries.load(Native Method) at java.base/jdk.internal.loader.NativeLibraries$NativeLibraryImpl.open(NativeLibraries.java:383) at java.base/jdk.internal.loader.NativeLibraries.loadLibrary(NativeLibraries.java:227) at java.base/jdk.internal.loader.NativeLibraries.loadLibrary(NativeLibraries.java:169) at java.base/java.lang.ClassLoader.loadLibrary(ClassLoader.java:2407) at java.base/java.lang.Runtime.load0(Runtime.java:747) at java.base/java.lang.System.load(System.java:1857) at arc.util.SharedLibraryLoader.loadFile(SharedLibraryLoader.java:294) at arc.backend.sdl.jni.SDL$3.loadFile(SDL.java:140) at arc.util.SharedLibraryLoader.loadFile(SharedLibraryLoader.java:260) ... 7 more ``` Let's add all SDL and alsa-lib as well. Instead of using propagatedBuildInputs let's embed store paths into a shell wrapper. --- pkgs/games/mindustry/default.nix | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/pkgs/games/mindustry/default.nix b/pkgs/games/mindustry/default.nix index 2572cd60c4a4..ff77f08651a0 100644 --- a/pkgs/games/mindustry/default.nix +++ b/pkgs/games/mindustry/default.nix @@ -128,15 +128,6 @@ stdenv.mkDerivation rec { rm Arc/backends/backend-sdl/libs/linux64/libsdl-arc*.so '' + cleanupMindustrySrc; - # Propagate glew to prevent it from being cleaned up. - # Since a jar is a compressed archive, nix can't figure out that the dependency is actually in there, - # and will assume that it's not actually needed. - # This can cause issues. - # See https://github.com/NixOS/nixpkgs/issues/109798. - propagatedBuildInputs = lib.optionals enableClient [ - glew.out - ]; - buildInputs = lib.optionals enableClient [ SDL2 glew @@ -183,6 +174,17 @@ stdenv.mkDerivation rec { makeWrapper ${jdk}/bin/java $out/bin/mindustry \ --add-flags "-jar $out/share/mindustry.jar" \ --set ALSA_PLUGIN_DIR ${alsa-plugins}/lib/alsa-lib/ + + # Retain runtime depends to prevent them from being cleaned up. + # Since a jar is a compressed archive, nix can't figure out that the dependency is actually in there, + # and will assume that it's not actually needed. + # This can cause issues. + # See https://github.com/NixOS/nixpkgs/issues/109798. + echo "# Retained runtime dependencies: " >> $out/bin/mindustry + for dep in ${SDL2.out} ${alsa-lib.out} ${glew.out}; do + echo "# $dep" >> $out/bin/mindustry + done + install -Dm644 core/assets/icons/icon_64.png $out/share/icons/hicolor/64x64/apps/mindustry.png '' + optionalString enableServer '' install -Dm644 server/build/libs/server-release.jar $out/share/mindustry-server.jar