From 97516c60341ddf1f753cb6f7a5ae8427d59b1aa2 Mon Sep 17 00:00:00 2001 From: Sefa Eyeoglu Date: Thu, 4 May 2023 17:18:52 +0200 Subject: [PATCH 1/5] prismlauncher: introduce unwrapped packages Signed-off-by: Sefa Eyeoglu --- pkgs/games/prismlauncher/default.nix | 49 +++--------------- pkgs/games/prismlauncher/wrapper.nix | 74 ++++++++++++++++++++++++++++ pkgs/top-level/all-packages.nix | 8 ++- 3 files changed, 86 insertions(+), 45 deletions(-) create mode 100644 pkgs/games/prismlauncher/wrapper.nix diff --git a/pkgs/games/prismlauncher/default.nix b/pkgs/games/prismlauncher/default.nix index 617dcc547473..58d4e4adfa81 100644 --- a/pkgs/games/prismlauncher/default.nix +++ b/pkgs/games/prismlauncher/default.nix @@ -3,29 +3,17 @@ , fetchFromGitHub , cmake , ninja -, jdk8 , jdk17 , zlib -, file -, wrapQtAppsHook -, xorg -, libpulseaudio , qtbase -, qtsvg -, qtwayland -, libGL , quazip -, glfw -, openal , extra-cmake-modules , tomlplusplus , ghc_filesystem -, msaClientID ? "" -, jdks ? [ jdk17 jdk8 ] -, gamemodeSupport ? true , gamemode +, msaClientID ? "" +, gamemodeSupport ? true }: - let libnbtplusplus = fetchFromGitHub { owner = "PrismLauncher"; @@ -34,9 +22,8 @@ let sha256 = "sha256-TvVOjkUobYJD9itQYueELJX3wmecvEdCbJ0FinW2mL4="; }; in - stdenv.mkDerivation rec { - pname = "prismlauncher"; + pname = "prismlauncher-unwrapped"; version = "6.3"; src = fetchFromGitHub { @@ -46,17 +33,14 @@ stdenv.mkDerivation rec { sha256 = "sha256-7tptHKWkbdxTn6VIPxXE1K3opKRiUW2zv9r6J05dcS8="; }; - nativeBuildInputs = [ extra-cmake-modules cmake file jdk17 ninja wrapQtAppsHook ]; + nativeBuildInputs = [ extra-cmake-modules cmake jdk17 ninja ]; buildInputs = [ qtbase - qtsvg zlib quazip ghc_filesystem tomlplusplus - ] - ++ lib.optional (lib.versionAtLeast qtbase.version "6") qtwayland - ++ lib.optional gamemodeSupport gamemode.dev; + ] ++ lib.optional gamemodeSupport gamemode; cmakeFlags = lib.optionals (msaClientID != "") [ "-DLauncher_MSA_CLIENT_ID=${msaClientID}" ] ++ lib.optionals (lib.versionAtLeast qtbase.version "6") [ "-DLauncher_QT_VERSION_MAJOR=6" ]; @@ -69,28 +53,7 @@ stdenv.mkDerivation rec { chown -R $USER: source/libraries/libnbtplusplus ''; - qtWrapperArgs = - let - libpath = with xorg; - lib.makeLibraryPath ([ - libX11 - libXext - libXcursor - libXrandr - libXxf86vm - libpulseaudio - libGL - glfw - openal - stdenv.cc.cc.lib - ] ++ lib.optional gamemodeSupport gamemode.lib); - in - [ - "--set LD_LIBRARY_PATH /run/opengl-driver/lib:${libpath}" - "--prefix PRISMLAUNCHER_JAVA_PATHS : ${lib.makeSearchPath "bin/java" jdks}" - # xorg.xrandr needed for LWJGL [2.9.2, 3) https://github.com/LWJGL/lwjgl/issues/128 - "--prefix PATH : ${lib.makeBinPath [xorg.xrandr]}" - ]; + dontWrapQtApps = true; meta = with lib; { homepage = "https://prismlauncher.org/"; diff --git a/pkgs/games/prismlauncher/wrapper.nix b/pkgs/games/prismlauncher/wrapper.nix new file mode 100644 index 000000000000..38480961f135 --- /dev/null +++ b/pkgs/games/prismlauncher/wrapper.nix @@ -0,0 +1,74 @@ +{ lib +, stdenv +, symlinkJoin +, prismlauncher-unwrapped +, wrapQtAppsHook +, qtbase # needed for wrapQtAppsHook +, qtsvg +, qtwayland +, xorg +, libpulseaudio +, libGL +, glfw +, openal +, jdk8 +, jdk17 +, jdks ? [ jdk17 jdk8 ] +, gamemode +, gamemodeSupport ? true +, additionalLibs ? [ ] +}: +let + prismlauncherFinal = prismlauncher-unwrapped.override { + inherit gamemodeSupport; + inherit gamemode; + }; +in +symlinkJoin { + name = "prismlauncher-${prismlauncherFinal.version}"; + + paths = [ prismlauncherFinal ]; + + nativeBuildInputs = [ + wrapQtAppsHook + ]; + + buildInputs = [ + qtbase + qtsvg + ] + ++ lib.optional (lib.versionAtLeast qtbase.version "6") qtwayland; + + postBuild = '' + wrapQtAppsHook + ''; + + qtWrapperArgs = + let + libs = (with xorg; [ + libX11 + libXext + libXcursor + libXrandr + libXxf86vm + ]) + ++ [ + libpulseaudio + libGL + glfw + openal + stdenv.cc.cc.lib + ] + ++ lib.optional gamemodeSupport gamemode.lib + ++ additionalLibs; + + in + [ + "--set LD_LIBRARY_PATH /run/opengl-driver/lib:${lib.makeLibraryPath libs}" + "--prefix PRISMLAUNCHER_JAVA_PATHS : ${lib.makeSearchPath "bin/java" jdks}" + # xorg.xrandr needed for LWJGL [2.9.2, 3) https://github.com/LWJGL/lwjgl/issues/128 + "--prefix PATH : ${lib.makeBinPath [xorg.xrandr]}" + ]; + + inherit (prismlauncherFinal) meta; +} diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 4a252b887935..60c0e7ceab47 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -36527,9 +36527,13 @@ with pkgs; principia = callPackage ../games/principia { }; - prismlauncher-qt5 = libsForQt5.callPackage ../games/prismlauncher { }; + prismlauncher-qt5-unwrapped = libsForQt5.callPackage ../games/prismlauncher { }; - prismlauncher = qt6Packages.callPackage ../games/prismlauncher { }; + prismlauncher-qt5 = libsForQt5.callPackage ../games/prismlauncher/wrapper.nix { prismlauncher-unwrapped = prismlauncher-qt5-unwrapped; }; + + prismlauncher-unwrapped = qt6Packages.callPackage ../games/prismlauncher { }; + + prismlauncher = qt6Packages.callPackage ../games/prismlauncher/wrapper.nix { }; pong3d = callPackage ../games/pong3d { }; From fa7b31cf86937f9be2eccf41265c947a35213554 Mon Sep 17 00:00:00 2001 From: Sefa Eyeoglu Date: Thu, 4 May 2023 17:23:31 +0200 Subject: [PATCH 2/5] prismlauncher: simplify postUnpack Signed-off-by: Sefa Eyeoglu --- pkgs/games/prismlauncher/default.nix | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/pkgs/games/prismlauncher/default.nix b/pkgs/games/prismlauncher/default.nix index 58d4e4adfa81..2761ab22f907 100644 --- a/pkgs/games/prismlauncher/default.nix +++ b/pkgs/games/prismlauncher/default.nix @@ -47,10 +47,7 @@ stdenv.mkDerivation rec { postUnpack = '' rm -rf source/libraries/libnbtplusplus - mkdir source/libraries/libnbtplusplus - ln -s ${libnbtplusplus}/* source/libraries/libnbtplusplus - chmod -R +r+w source/libraries/libnbtplusplus - chown -R $USER: source/libraries/libnbtplusplus + ln -s ${libnbtplusplus} source/libraries/libnbtplusplus ''; dontWrapQtApps = true; From b130e618d6e657e6b1bc6a419926c3559da6fa9f Mon Sep 17 00:00:00 2001 From: Sefa Eyeoglu Date: Thu, 4 May 2023 17:24:17 +0200 Subject: [PATCH 3/5] prismlauncher: allow empty msaClientID Upstream supports leaving the value empty, which effectively disables the code related to that client id. Signed-off-by: Sefa Eyeoglu --- pkgs/games/prismlauncher/default.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/games/prismlauncher/default.nix b/pkgs/games/prismlauncher/default.nix index 2761ab22f907..2e7defef059d 100644 --- a/pkgs/games/prismlauncher/default.nix +++ b/pkgs/games/prismlauncher/default.nix @@ -11,7 +11,7 @@ , tomlplusplus , ghc_filesystem , gamemode -, msaClientID ? "" +, msaClientID ? null , gamemodeSupport ? true }: let @@ -42,7 +42,7 @@ stdenv.mkDerivation rec { tomlplusplus ] ++ lib.optional gamemodeSupport gamemode; - cmakeFlags = lib.optionals (msaClientID != "") [ "-DLauncher_MSA_CLIENT_ID=${msaClientID}" ] + cmakeFlags = lib.optionals (msaClientID != null) [ "-DLauncher_MSA_CLIENT_ID=${msaClientID}" ] ++ lib.optionals (lib.versionAtLeast qtbase.version "6") [ "-DLauncher_QT_VERSION_MAJOR=6" ]; postUnpack = '' From 26dda3c45ebdc910527a1f18bce360034bdbdb96 Mon Sep 17 00:00:00 2001 From: Sefa Eyeoglu Date: Sat, 6 May 2023 21:59:55 +0200 Subject: [PATCH 4/5] prismlauncher: enable PIE Signed-off-by: Sefa Eyeoglu --- pkgs/games/prismlauncher/default.nix | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pkgs/games/prismlauncher/default.nix b/pkgs/games/prismlauncher/default.nix index 2e7defef059d..eb83de0d0b65 100644 --- a/pkgs/games/prismlauncher/default.nix +++ b/pkgs/games/prismlauncher/default.nix @@ -42,6 +42,8 @@ stdenv.mkDerivation rec { tomlplusplus ] ++ lib.optional gamemodeSupport gamemode; + hardeningEnable = [ "pie" ]; + cmakeFlags = lib.optionals (msaClientID != null) [ "-DLauncher_MSA_CLIENT_ID=${msaClientID}" ] ++ lib.optionals (lib.versionAtLeast qtbase.version "6") [ "-DLauncher_QT_VERSION_MAJOR=6" ]; From e17bf7b2723b4ebfb200473b6bc56b2abac271ba Mon Sep 17 00:00:00 2001 From: Sefa Eyeoglu Date: Mon, 15 May 2023 10:34:03 +0200 Subject: [PATCH 5/5] prismlauncher: expose parameters of unwrapped package Signed-off-by: Sefa Eyeoglu --- pkgs/games/prismlauncher/wrapper.nix | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/pkgs/games/prismlauncher/wrapper.nix b/pkgs/games/prismlauncher/wrapper.nix index 38480961f135..57d85f4800d3 100644 --- a/pkgs/games/prismlauncher/wrapper.nix +++ b/pkgs/games/prismlauncher/wrapper.nix @@ -13,15 +13,16 @@ , openal , jdk8 , jdk17 -, jdks ? [ jdk17 jdk8 ] , gamemode + +, msaClientID ? null , gamemodeSupport ? true +, jdks ? [ jdk17 jdk8 ] , additionalLibs ? [ ] }: let prismlauncherFinal = prismlauncher-unwrapped.override { - inherit gamemodeSupport; - inherit gamemode; + inherit msaClientID gamemodeSupport; }; in symlinkJoin {