From cc4bb3d6728d249f4450e3587644c8203465685a Mon Sep 17 00:00:00 2001 From: seth Date: Mon, 4 Sep 2023 15:10:41 -0400 Subject: [PATCH 1/4] prismlauncher: add withWaylandGLFW override --- pkgs/games/prismlauncher/wrapper.nix | 41 +++++++++++++++++++++------- 1 file changed, 31 insertions(+), 10 deletions(-) diff --git a/pkgs/games/prismlauncher/wrapper.nix b/pkgs/games/prismlauncher/wrapper.nix index 4b0aa418fb6a..761f86fa1cb5 100644 --- a/pkgs/games/prismlauncher/wrapper.nix +++ b/pkgs/games/prismlauncher/wrapper.nix @@ -1,9 +1,12 @@ { lib , stdenv , symlinkJoin -, prismlauncher-unwrapped +, makeWrapper , wrapQtAppsHook , addOpenGLRunpath + +, prismlauncher-unwrapped + , qtbase # needed for wrapQtAppsHook , qtsvg , qtwayland @@ -11,6 +14,7 @@ , libpulseaudio , libGL , glfw +, glfw-wayland-minecraft , openal , jdk8 , jdk17 @@ -24,10 +28,17 @@ , gamemodeSupport ? stdenv.isLinux , textToSpeechSupport ? stdenv.isLinux , controllerSupport ? stdenv.isLinux +, withWaylandGLFW ? false +, shellWrapper ? withWaylandGLFW + , jdks ? [ jdk17 jdk8 ] , additionalLibs ? [ ] , additionalPrograms ? [ ] }: + +assert lib.assertMsg (withWaylandGLFW -> stdenv.isLinux) "withWaylandGLFW is only available on Linux"; +assert lib.assertMsg (withWaylandGLFW -> shellWrapper) "withWaylandGLFW requires shellWrapper"; + let prismlauncherFinal = prismlauncher-unwrapped.override { inherit msaClientID gamemodeSupport; @@ -40,7 +51,8 @@ symlinkJoin { nativeBuildInputs = [ wrapQtAppsHook - ]; + ] + ++ lib.optional shellWrapper makeWrapper; buildInputs = [ qtbase @@ -48,20 +60,29 @@ symlinkJoin { ] ++ lib.optional (lib.versionAtLeast qtbase.version "6" && stdenv.isLinux) qtwayland; + waylandPreExec = '' + if [ -n "$WAYLAND_DISPLAY" ]; then + export LD_LIBRARY_PATH=${lib.getLib glfw-wayland-minecraft}/lib:"$LD_LIBRARY_PATH" + fi + ''; + postBuild = '' + ${lib.optionalString withWaylandGLFW '' + qtWrapperArgs+=(--run "$waylandPreExec") + ''} + wrapQtAppsHook ''; qtWrapperArgs = let - runtimeLibs = (with xorg; [ - libX11 - libXext - libXcursor - libXrandr - libXxf86vm - ]) - ++ [ + runtimeLibs = [ + xorg.libX11 + xorg.libXext + xorg.libXcursor + xorg.libXrandr + xorg.libXxf86vm + # lwjgl libpulseaudio libGL From 915431fb2d5680e5d66083a83ffb8da353626594 Mon Sep 17 00:00:00 2001 From: Jacob Birkett Date: Mon, 11 Sep 2023 14:57:05 -0700 Subject: [PATCH 2/4] prismlauncher: add comments explaining new args --- pkgs/games/prismlauncher/wrapper.nix | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/pkgs/games/prismlauncher/wrapper.nix b/pkgs/games/prismlauncher/wrapper.nix index 761f86fa1cb5..26edf7972a94 100644 --- a/pkgs/games/prismlauncher/wrapper.nix +++ b/pkgs/games/prismlauncher/wrapper.nix @@ -28,7 +28,18 @@ , gamemodeSupport ? stdenv.isLinux , textToSpeechSupport ? stdenv.isLinux , controllerSupport ? stdenv.isLinux + +# The flag `withWaylandGLFW` enables runtime-checking of `WAYLAND_DISPLAY`; +# if the option is enabled, a patched version of GLFW will be added to +# `LD_LIBRARY_PATH` so that the launcher can use the correct one +# depending on the desktop environment used. , withWaylandGLFW ? false +# By default, this package uses a binary wrapper for `wrapQtAppsHook`. +# Enabling `shellWrapper` will add `makeWrapper` to `nativeBuildInputs`, +# causing `wrapQtAppsHook` to output a shell wrapper instead. +# This is needed for checking environment variables at runtime +# and modifying others if necessary (see above option for example). +# Warning: This can make the program start slower, by about four milliseconds. , shellWrapper ? withWaylandGLFW , jdks ? [ jdk17 jdk8 ] From 8be05482df410454a2e59d456ddc643f4a3bd261 Mon Sep 17 00:00:00 2001 From: Jacob Birkett Date: Wed, 4 Oct 2023 22:31:48 -0700 Subject: [PATCH 3/4] prismlauncher: move shellWrapper to let block --- pkgs/games/prismlauncher/wrapper.nix | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/pkgs/games/prismlauncher/wrapper.nix b/pkgs/games/prismlauncher/wrapper.nix index 26edf7972a94..b2fd4f656f87 100644 --- a/pkgs/games/prismlauncher/wrapper.nix +++ b/pkgs/games/prismlauncher/wrapper.nix @@ -34,13 +34,6 @@ # `LD_LIBRARY_PATH` so that the launcher can use the correct one # depending on the desktop environment used. , withWaylandGLFW ? false -# By default, this package uses a binary wrapper for `wrapQtAppsHook`. -# Enabling `shellWrapper` will add `makeWrapper` to `nativeBuildInputs`, -# causing `wrapQtAppsHook` to output a shell wrapper instead. -# This is needed for checking environment variables at runtime -# and modifying others if necessary (see above option for example). -# Warning: This can make the program start slower, by about four milliseconds. -, shellWrapper ? withWaylandGLFW , jdks ? [ jdk17 jdk8 ] , additionalLibs ? [ ] @@ -48,13 +41,21 @@ }: assert lib.assertMsg (withWaylandGLFW -> stdenv.isLinux) "withWaylandGLFW is only available on Linux"; -assert lib.assertMsg (withWaylandGLFW -> shellWrapper) "withWaylandGLFW requires shellWrapper"; let + # By default, this package uses a binary wrapper for `wrapQtAppsHook`. + # Enabling `shellWrapper` will add `makeWrapper` to `nativeBuildInputs`, + # causing `wrapQtAppsHook` to output a shell wrapper instead. + # This is needed for checking environment variables at runtime + # and modifying others if necessary (see above option for example). + # Warning: This can make the program start slower, by about four milliseconds. + shellWrapper = withWaylandGLFW; + prismlauncherFinal = prismlauncher-unwrapped.override { inherit msaClientID gamemodeSupport; }; in + symlinkJoin { name = "prismlauncher-${prismlauncherFinal.version}"; From 9175b939c1d382685ed6f04dda0a66c6d1e6810f Mon Sep 17 00:00:00 2001 From: Jacob Birkett Date: Wed, 4 Oct 2023 22:34:20 -0700 Subject: [PATCH 4/4] prismlauncher: give interm. package accurate name --- pkgs/games/prismlauncher/wrapper.nix | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pkgs/games/prismlauncher/wrapper.nix b/pkgs/games/prismlauncher/wrapper.nix index b2fd4f656f87..12ba774b06c7 100644 --- a/pkgs/games/prismlauncher/wrapper.nix +++ b/pkgs/games/prismlauncher/wrapper.nix @@ -51,15 +51,15 @@ let # Warning: This can make the program start slower, by about four milliseconds. shellWrapper = withWaylandGLFW; - prismlauncherFinal = prismlauncher-unwrapped.override { + prismlauncher' = prismlauncher-unwrapped.override { inherit msaClientID gamemodeSupport; }; in symlinkJoin { - name = "prismlauncher-${prismlauncherFinal.version}"; + name = "prismlauncher-${prismlauncher'.version}"; - paths = [ prismlauncherFinal ]; + paths = [ prismlauncher' ]; nativeBuildInputs = [ wrapQtAppsHook @@ -124,5 +124,5 @@ symlinkJoin { "--prefix PATH : ${lib.makeBinPath runtimePrograms}" ]; - inherit (prismlauncherFinal) meta; + inherit (prismlauncher') meta; }