Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

prismlauncher: 8.3 -> 8.4; refactor #321851

Merged
merged 7 commits into from
Jun 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
117 changes: 117 additions & 0 deletions pkgs/by-name/pr/prismlauncher-unwrapped/package.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
{
lib,
stdenv,
fetchFromGitHub,
cmake,
cmark,
darwin,
extra-cmake-modules,
gamemode,
ghc_filesystem,
jdk17,
kdePackages,
ninja,
nix-update-script,
stripJavaArchivesHook,
tomlplusplus,
zlib,

msaClientID ? null,
gamemodeSupport ? stdenv.isLinux,
}:

let
libnbtplusplus = fetchFromGitHub {
owner = "PrismLauncher";
repo = "libnbtplusplus";
rev = "a5e8fd52b8bf4ab5d5bcc042b2a247867589985f";
hash = "sha256-A5kTgICnx+Qdq3Fir/bKTfdTt/T1NQP2SC+nhN1ENug=";
};
in

assert lib.assertMsg (
gamemodeSupport -> stdenv.isLinux
) "gamemodeSupport is only available on Linux.";

stdenv.mkDerivation (finalAttrs: {
pname = "prismlauncher-unwrapped";
version = "8.4";

src = fetchFromGitHub {
owner = "PrismLauncher";
repo = "PrismLauncher";
rev = finalAttrs.version;
hash = "sha256-460hB91M2hZm+uU1tywJEj20oRd5cz/NDvya8/vJdSA=";
};

postUnpack = ''
rm -rf source/libraries/libnbtplusplus
ln -s ${libnbtplusplus} source/libraries/libnbtplusplus
'';

nativeBuildInputs = [
cmake
ninja
extra-cmake-modules
jdk17
stripJavaArchivesHook
];

buildInputs =
[
cmark
ghc_filesystem
kdePackages.qtbase
kdePackages.quazip
tomlplusplus
zlib
]
++ lib.optionals stdenv.isDarwin [ darwin.apple_sdk.frameworks.Cocoa ]
++ lib.optional gamemodeSupport gamemode;

hardeningEnable = lib.optionals stdenv.isLinux [ "pie" ];

cmakeFlags =
[
# downstream branding
(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;

passthru = {
updateScript = nix-update-script { };
};

meta = {
description = "Free, open source launcher for Minecraft";
longDescription = ''
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 associated options with a simple interface.
'';
homepage = "https://prismlauncher.org/";
changelog = "https://github.com/PrismLauncher/PrismLauncher/releases/tag/${finalAttrs.src.rev}";
license = lib.licenses.gpl3Only;
maintainers = with lib.maintainers; [
minion3665
Scrumplex
getchoo
];
mainProgram = "prismlauncher";
platforms = lib.platforms.linux ++ lib.platforms.darwin;
};
})
151 changes: 151 additions & 0 deletions pkgs/by-name/pr/prismlauncher/package.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
{
lib,
stdenv,
symlinkJoin,
prismlauncher-unwrapped,
addOpenGLRunpath,
flite,
gamemode,
glfw,
glfw-wayland-minecraft,
glxinfo,
jdk8,
jdk17,
jdk21,
kdePackages,
libGL,
libpulseaudio,
libusb1,
makeWrapper,
openal,
pciutils,
udev,
vulkan-loader,
xorg,

additionalLibs ? [ ],
additionalPrograms ? [ ],
controllerSupport ? stdenv.isLinux,
gamemodeSupport ? stdenv.isLinux,
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

symlinkJoin {
name = "prismlauncher-${prismlauncher'.version}";

paths = [ prismlauncher' ];

nativeBuildInputs =
[ kdePackages.wrapQtAppsHook ]
# purposefully using a shell wrapper here for variable expansion
# see https://github.com/NixOS/nixpkgs/issues/172583
++ lib.optional withWaylandGLFW makeWrapper;

buildInputs =
[
kdePackages.qtbase
kdePackages.qtsvg
]
++ lib.optional (
lib.versionAtLeast kdePackages.qtbase.version "6" && stdenv.isLinux
) kdePackages.qtwayland;

env = {
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
runtimeLibs =
[
# lwjgl
glfw
libpulseaudio
libGL
openal
stdenv.cc.cc.lib

vulkan-loader # VulkanMod's lwjgl

udev # oshi

xorg.libX11
xorg.libXext
xorg.libXcursor
xorg.libXrandr
xorg.libXxf86vm
]
++ lib.optional textToSpeechSupport flite
++ lib.optional gamemodeSupport gamemode.lib
++ lib.optional controllerSupport libusb1
++ additionalLibs;

runtimePrograms = [
glxinfo
pciutils # need lspci
xorg.xrandr # needed for LWJGL [2.9.2, 3) https://github.com/LWJGL/lwjgl/issues/128
] ++ additionalPrograms;

in
[ "--prefix PRISMLAUNCHER_JAVA_PATHS : ${lib.makeSearchPath "bin/java" jdks}" ]
++ lib.optionals stdenv.isLinux [
"--set LD_LIBRARY_PATH ${addOpenGLRunpath.driverLink}/lib:${lib.makeLibraryPath runtimeLibs}"
"--prefix PATH : ${lib.makeBinPath runtimePrograms}"
];

meta = {
inherit (prismlauncher'.meta)
description
longDescription
homepage
changelog
license
maintainers
mainProgram
platforms
;
};
}
90 changes: 0 additions & 90 deletions pkgs/games/prismlauncher/default.nix

This file was deleted.

Loading