From 729d2eea291e74fab6e50d3ae95d4396f7784e28 Mon Sep 17 00:00:00 2001 From: Ryan Hendrickson Date: Fri, 21 Apr 2023 04:23:40 -0400 Subject: [PATCH] mindustry-wayland: set SDL environment variables `SDL_VIDEODRIVER=wayland` seems to be a requirement for GLEW to initialize when using glew-egl. `SDL_VIDEO_WAYLAND_WMCLASS` associates the application with the .desktop file (in GNOME Shell, at least, if not other Wayland desktops). --- pkgs/games/mindustry/default.nix | 16 ++++++++++++---- pkgs/top-level/all-packages.nix | 2 +- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/pkgs/games/mindustry/default.nix b/pkgs/games/mindustry/default.nix index 45991d7c5518..5a76f755a9b3 100644 --- a/pkgs/games/mindustry/default.nix +++ b/pkgs/games/mindustry/default.nix @@ -15,6 +15,7 @@ , alsa-lib , alsa-plugins , glew +, glew-egl # for soloud , libpulseaudio ? null @@ -30,6 +31,8 @@ , makeBuildVersion ? (v: v) , enableClient ? true , enableServer ? true + +, enableWayland ? false }: let @@ -37,6 +40,8 @@ let version = "142"; buildVersion = makeBuildVersion version; + selectedGlew = if enableWayland then glew-egl else glew; + Mindustry = fetchFromGitHub { owner = "Anuken"; repo = "Mindustry"; @@ -139,7 +144,7 @@ stdenv.mkDerivation rec { buildInputs = lib.optionals enableClient [ SDL2 - glew + selectedGlew alsa-lib ]; nativeBuildInputs = [ @@ -171,7 +176,7 @@ stdenv.mkDerivation rec { pushd ../Arc gradle --offline --no-daemon jnigenBuild -Pbuildversion=${buildVersion} gradle --offline --no-daemon jnigenJarNativesDesktop -Pbuildversion=${buildVersion} - glewlib=${lib.getLib glew}/lib/libGLEW.so + glewlib=${lib.getLib selectedGlew}/lib/libGLEW.so sdllib=${lib.getLib SDL2}/lib/libSDL2.so patchelf backends/backend-sdl/libs/linux64/libsdl-arc*.so \ --add-needed $glewlib \ @@ -194,7 +199,10 @@ stdenv.mkDerivation rec { makeWrapper ${jdk}/bin/java $out/bin/mindustry \ --add-flags "-jar $out/share/mindustry.jar" \ --suffix LD_LIBRARY_PATH : ${lib.makeLibraryPath [libpulseaudio alsa-lib libjack2]} \ - --set ALSA_PLUGIN_DIR ${alsa-plugins}/lib/alsa-lib/ + --set ALSA_PLUGIN_DIR ${alsa-plugins}/lib/alsa-lib/'' + optionalString enableWayland '' \ + --set SDL_VIDEODRIVER wayland \ + --set SDL_VIDEO_WAYLAND_WMCLASS Mindustry + '' + '' # 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, @@ -202,7 +210,7 @@ stdenv.mkDerivation rec { # 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 + for dep in ${SDL2.out} ${alsa-lib.out} ${selectedGlew.out}; do echo "# $dep" >> $out/bin/mindustry done diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 1ce71032d5e7..dcdd3d8bd54e 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -35754,7 +35754,7 @@ with pkgs; mindustry = callPackage ../games/mindustry { }; mindustry-wayland = callPackage ../games/mindustry { - glew = glew-egl; + enableWayland = true; }; mindustry-server = callPackage ../games/mindustry {