nix: sync changes from nixpkgs

Brings in changes from the Prism Launcher derivation(s) in nixpkgs, notably
from https://github.com/NixOS/nixpkgs/pull/321851 and
https://github.com/NixOS/nixpkgs/pull/303880

Signed-off-by: Evan Goode <mail@evangoo.de>
This commit is contained in:
Evan Goode 2024-07-20 18:40:32 -04:00
parent 6352362907
commit ff31e88cf8
3 changed files with 160 additions and 93 deletions

View File

@ -24,9 +24,8 @@
overlays.default = final: prev: let overlays.default = final: prev: let
version = builtins.substring 0 8 self.lastModifiedDate or "dirty"; version = builtins.substring 0 8 self.lastModifiedDate or "dirty";
in { in {
prismlauncher-unwrapped = prev.qt6Packages.callPackage ./pkg { prismlauncher-unwrapped = prev.callPackage ./pkg {
inherit (inputs) libnbtplusplus; inherit (inputs) libnbtplusplus;
inherit ((final.darwin or prev.darwin).apple_sdk.frameworks) Cocoa;
inherit version; inherit version;
}; };

View File

@ -1,27 +1,27 @@
{ {
lib, lib,
stdenv, stdenv,
canonicalize-jars-hook,
cmake, cmake,
cmark, cmark,
Cocoa, darwin,
ninja,
jdk17,
zlib,
qtbase,
qtnetworkauth,
quazip,
extra-cmake-modules, extra-cmake-modules,
tomlplusplus,
ghc_filesystem,
gamemode, gamemode,
ghc_filesystem,
jdk17,
kdePackages,
ninja,
stripJavaArchivesHook,
tomlplusplus,
zlib,
msaClientID ? null, msaClientID ? null,
gamemodeSupport ? stdenv.isLinux, gamemodeSupport ? stdenv.isLinux,
version, version,
libnbtplusplus, libnbtplusplus,
}: }:
assert lib.assertMsg (stdenv.isLinux || !gamemodeSupport) "gamemodeSupport is only available on Linux"; assert lib.assertMsg (
stdenv.mkDerivation rec { gamemodeSupport -> stdenv.isLinux
) "gamemodeSupport is only available on Linux.";
stdenv.mkDerivation {
pname = "prismlauncher-unwrapped"; pname = "prismlauncher-unwrapped";
inherit version; inherit version;
@ -39,49 +39,68 @@ assert lib.assertMsg (stdenv.isLinux || !gamemodeSupport) "gamemodeSupport is on
]); ]);
}; };
nativeBuildInputs = [extra-cmake-modules cmake jdk17 ninja canonicalize-jars-hook];
buildInputs =
[
qtbase
qtnetworkauth
zlib
quazip
ghc_filesystem
tomlplusplus
cmark
]
++ lib.optional gamemodeSupport gamemode
++ lib.optionals stdenv.isDarwin [Cocoa];
hardeningEnable = lib.optionals stdenv.isLinux ["pie"];
cmakeFlags =
[
"-DLauncher_BUILD_PLATFORM=nixpkgs"
]
++ lib.optionals (msaClientID != null) ["-DLauncher_MSA_CLIENT_ID=${msaClientID}"]
++ lib.optionals (lib.versionOlder qtbase.version "6") ["-DLauncher_QT_VERSION_MAJOR=5"]
++ lib.optionals stdenv.isDarwin ["-DINSTALL_BUNDLE=nodeps" "-DMACOSX_SPARKLE_UPDATE_FEED_URL=''"];
postUnpack = '' postUnpack = ''
rm -rf source/libraries/libnbtplusplus rm -rf source/libraries/libnbtplusplus
ln -s ${libnbtplusplus} source/libraries/libnbtplusplus ln -s ${libnbtplusplus} source/libraries/libnbtplusplus
''; '';
nativeBuildInputs = [
cmake
ninja
extra-cmake-modules
jdk17
stripJavaArchivesHook
];
buildInputs =
[
cmark
ghc_filesystem
kdePackages.qtbase
kdePackages.qtnetworkauth
kdePackages.quazip
tomlplusplus
zlib
]
++ lib.optionals stdenv.isDarwin [darwin.apple_sdk.frameworks.Cocoa]
++ lib.optional gamemodeSupport gamemode;
hardeningEnable = lib.optionals stdenv.isLinux ["pie"];
cmakeFlags =
[
(lib.cmakeFeature "Launcher_BUILD_PLATFORM" "nixpkgs")
]
++ lib.optionals (msaClientID != null) [
(lib.cmakeFeature "Launcher_MSA_CLIENT_ID" (toString msaClientID))
]
++ lib.optionals (lib.versionOlder kdePackages.qtbase.version "6") [
(lib.cmakeFeature "Launcher_QT_VERSION_MAJOR" "5")
]
++ lib.optionals stdenv.isDarwin [
# we wrap our binary manually
(lib.cmakeFeature "INSTALL_BUNDLE" "nodeps")
# disable built-in updater
(lib.cmakeFeature "MACOSX_SPARKLE_UPDATE_FEED_URL" "''")
(lib.cmakeFeature "CMAKE_INSTALL_PREFIX" "${placeholder "out"}/Applications/")
];
dontWrapQtApps = true; dontWrapQtApps = true;
meta = with lib; { meta = {
mainProgram = "prismlauncher"; description = "Free, open source launcher for Minecraft";
homepage = "https://prismlauncher.org/";
description = "A free, open source launcher for Minecraft";
longDescription = '' longDescription = ''
Allows you to have multiple, separate instances of Minecraft (each with Allows you to have multiple, separate instances of Minecraft (each with
their own mods, texture packs, saves, etc) and helps you manage them and their own mods, texture packs, saves, etc) and helps you manage them and
their associated options with a simple interface. their associated options with a simple interface.
''; '';
platforms = with platforms; linux ++ darwin; homepage = "https://prismlauncher.org/";
changelog = "https://github.com/PrismLauncher/PrismLauncher/releases/tag/${version}"; license = lib.licenses.gpl3Only;
license = licenses.gpl3Only; maintainers = with lib.maintainers; [
maintainers = with maintainers; [minion3665 Scrumplex getchoo]; Scrumplex
getchoo
];
mainProgram = "prismlauncher";
platforms = lib.platforms.linux ++ lib.platforms.darwin;
}; };
} }

View File

@ -3,94 +3,143 @@
stdenv, stdenv,
symlinkJoin, symlinkJoin,
prismlauncher-unwrapped, prismlauncher-unwrapped,
wrapQtAppsHook,
addOpenGLRunpath, addOpenGLRunpath,
qtbase, # needed for wrapQtAppsHook flite,
qtsvg, gamemode,
qtwayland,
xorg,
libpulseaudio,
libGL,
glfw, glfw,
openal, glfw-wayland-minecraft,
glxinfo,
jdk8, jdk8,
jdk17, jdk17,
jdk21, jdk21,
gamemode, kdePackages,
flite, libGL,
glxinfo, libpulseaudio,
udev,
libusb1, libusb1,
msaClientID ? null, makeWrapper,
gamemodeSupport ? stdenv.isLinux, openal,
textToSpeechSupport ? stdenv.isLinux, pciutils,
controllerSupport ? stdenv.isLinux, udev,
jdks ? [jdk21 jdk17 jdk8], vulkan-loader,
xorg,
additionalLibs ? [], additionalLibs ? [],
additionalPrograms ? [], additionalPrograms ? [],
}: let controllerSupport ? stdenv.isLinux,
prismlauncherFinal = prismlauncher-unwrapped.override { gamemodeSupport ? stdenv.isLinux,
inherit msaClientID gamemodeSupport; jdks ? [
}; jdk21
jdk17
jdk8
],
msaClientID ? null,
textToSpeechSupport ? stdenv.isLinux,
# Adds `glfw-wayland-minecraft` to `LD_LIBRARY_PATH`
# when launched on wayland, allowing for the game to be run natively.
# Make sure to enable "Use system installation of GLFW" in instance settings
# for this to take effect
#
# Warning: This build of glfw may be unstable, and the launcher
# itself can take slightly longer to start
withWaylandGLFW ? false,
}:
assert lib.assertMsg (
controllerSupport -> stdenv.isLinux
) "controllerSupport only has an effect on Linux.";
assert lib.assertMsg (
textToSpeechSupport -> stdenv.isLinux
) "textToSpeechSupport only has an effect on Linux.";
assert lib.assertMsg (
withWaylandGLFW -> stdenv.isLinux
) "withWaylandGLFW is only available on Linux."; let
prismlauncher' = prismlauncher-unwrapped.override {inherit msaClientID gamemodeSupport;};
in in
symlinkJoin { symlinkJoin {
name = "prismlauncher-${prismlauncherFinal.version}"; name = "prismlauncher-${prismlauncher'.version}";
paths = [prismlauncherFinal]; paths = [prismlauncher'];
nativeBuildInputs = [ nativeBuildInputs =
wrapQtAppsHook [kdePackages.wrapQtAppsHook]
]; # purposefully using a shell wrapper here for variable expansion
# see https://github.com/NixOS/nixpkgs/issues/172583
++ lib.optional withWaylandGLFW makeWrapper;
buildInputs = buildInputs =
[ [
qtbase kdePackages.qtbase
qtsvg kdePackages.qtsvg
] ]
++ lib.optional (lib.versionAtLeast qtbase.version "6" && stdenv.isLinux) qtwayland; ++ lib.optional (
lib.versionAtLeast kdePackages.qtbase.version "6" && stdenv.isLinux
)
kdePackages.qtwayland;
postBuild = '' env = {
wrapQtAppsHook waylandPreExec = lib.optionalString withWaylandGLFW ''
''; 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 qtWrapperArgs = let
runtimeLibs = runtimeLibs =
(with xorg; [ [
libX11
libXext
libXcursor
libXrandr
libXxf86vm
])
++ [
# lwjgl # lwjgl
glfw
libpulseaudio libpulseaudio
libGL libGL
glfw
openal openal
stdenv.cc.cc.lib stdenv.cc.cc.lib
# oshi vulkan-loader # VulkanMod's lwjgl
udev
udev # oshi
xorg.libX11
xorg.libXext
xorg.libXcursor
xorg.libXrandr
xorg.libXxf86vm
] ]
++ lib.optional gamemodeSupport gamemode.lib
++ lib.optional textToSpeechSupport flite ++ lib.optional textToSpeechSupport flite
++ lib.optional gamemodeSupport gamemode.lib
++ lib.optional controllerSupport libusb1 ++ lib.optional controllerSupport libusb1
++ additionalLibs; ++ additionalLibs;
runtimePrograms = runtimePrograms =
[ [
xorg.xrandr
glxinfo glxinfo
pciutils # need lspci
xorg.xrandr # needed for LWJGL [2.9.2, 3) https://github.com/LWJGL/lwjgl/issues/128
] ]
++ additionalPrograms; ++ additionalPrograms;
in in
["--prefix PRISMLAUNCHER_JAVA_PATHS : ${lib.makeSearchPath "bin/java" jdks}"] ["--prefix PRISMLAUNCHER_JAVA_PATHS : ${lib.makeSearchPath "bin/java" jdks}"]
++ lib.optionals stdenv.isLinux [ ++ lib.optionals stdenv.isLinux [
"--set LD_LIBRARY_PATH ${addOpenGLRunpath.driverLink}/lib:${lib.makeLibraryPath runtimeLibs}" "--set LD_LIBRARY_PATH ${addOpenGLRunpath.driverLink}/lib:${lib.makeLibraryPath runtimeLibs}"
# xorg.xrandr needed for LWJGL [2.9.2, 3) https://github.com/LWJGL/lwjgl/issues/128
"--prefix PATH : ${lib.makeBinPath runtimePrograms}" "--prefix PATH : ${lib.makeBinPath runtimePrograms}"
]; ];
inherit (prismlauncherFinal) meta; meta = {
inherit
(prismlauncher'.meta)
description
longDescription
homepage
changelog
license
maintainers
mainProgram
platforms
;
};
} }