prismlauncher: add support for darwin

This commit is contained in:
seth 2023-07-20 20:21:57 -04:00
parent 65cd0b72b5
commit 7ed803a136
No known key found for this signature in database
GPG key ID: D31BD0D494BBEE86
3 changed files with 61 additions and 20 deletions

View file

@ -1,8 +1,10 @@
{ lib { lib
, stdenv , stdenv
, fetchFromGitHub , fetchFromGitHub
, fetchpatch
, cmake , cmake
, cmark , cmark
, Cocoa
, ninja , ninja
, jdk17 , jdk17
, zlib , zlib
@ -13,7 +15,8 @@
, ghc_filesystem , ghc_filesystem
, gamemode , gamemode
, msaClientID ? null , msaClientID ? null
, gamemodeSupport ? true , gamemodeSupport ? stdenv.isLinux
,
}: }:
let let
libnbtplusplus = fetchFromGitHub { libnbtplusplus = fetchFromGitHub {
@ -23,7 +26,11 @@ let
sha256 = "sha256-TvVOjkUobYJD9itQYueELJX3wmecvEdCbJ0FinW2mL4="; sha256 = "sha256-TvVOjkUobYJD9itQYueELJX3wmecvEdCbJ0FinW2mL4=";
}; };
in in
stdenv.mkDerivation rec {
assert lib.assertMsg (stdenv.isLinux || !gamemodeSupport) "gamemodeSupport is only available on Linux";
stdenv.mkDerivation
rec {
pname = "prismlauncher-unwrapped"; pname = "prismlauncher-unwrapped";
version = "7.2"; version = "7.2";
@ -34,23 +41,53 @@ stdenv.mkDerivation rec {
sha256 = "sha256-RArg60S91YKp1Mt97a5JNfBEOf2cmuX4pK3VAx2WfqM="; sha256 = "sha256-RArg60S91YKp1Mt97a5JNfBEOf2cmuX4pK3VAx2WfqM=";
}; };
nativeBuildInputs = [ extra-cmake-modules cmake jdk17 ninja ]; patches = lib.optionals stdenv.isDarwin [
buildInputs = [ # https://github.com/PrismLauncher/PrismLauncher/pull/1452
qtbase # These patches allow us to disable the Sparkle updater and cmake bundling
zlib # TODO: remove these when updating to 8.0
quazip (fetchpatch {
ghc_filesystem name = "disable-sparkle-when-url-is-empty.patch";
tomlplusplus url = "https://github.com/PrismLauncher/PrismLauncher/commit/48e50401968a72846350c6fbd76cc957b64a6b5a.patch";
cmark hash = "sha256-IFxp6Sj87ogQcMooV4Ql5/4B+C7oTzEk+4tlMud2OLo=";
] ++ lib.optional gamemodeSupport gamemode; })
(fetchpatch {
name = "make-install_bundle-cached.patch";
url = "https://github.com/PrismLauncher/PrismLauncher/commit/a8498b0dab94d0ab6c9e5cf395e5003db541b749.patch";
hash = "sha256-ji5GGUnzVut9xFXkynqf9aVR9FO/zsqIbt3P9dexJ2I=";
})
(fetchpatch {
name = "dont-include-sparkle-when-not-enabled.patch";
url = "https://github.com/PrismLauncher/PrismLauncher/commit/51bfda937d47837ed426150ed6f43a60b4ca0ce1.patch";
hash = "sha256-7hMgANOg4zRIf3F2AfLXGR3dAEBqVmKm/J5SH0G5oCk=";
})
(fetchpatch {
name = "introduce-internal-updater-variable.patch";
url = "https://github.com/PrismLauncher/PrismLauncher/commit/b1aa9e584624a0732dd55fc6c459524a8abfe6ba.patch";
hash = "sha256-mm++EfnBxz7NVtKLMb889mMq8F/OdQmzob8OmlvNlRA=";
})
];
hardeningEnable = [ "pie" ]; nativeBuildInputs = [ extra-cmake-modules cmake jdk17 ninja ];
buildInputs =
[
qtbase
zlib
quazip
ghc_filesystem
tomlplusplus
cmark
]
++ lib.optional gamemodeSupport gamemode
++ lib.optionals stdenv.isDarwin [ Cocoa ];
hardeningEnable = lib.optionals stdenv.isLinux [ "pie" ];
cmakeFlags = [ cmakeFlags = [
# downstream branding # downstream branding
"-DLauncher_BUILD_PLATFORM=nixpkgs" "-DLauncher_BUILD_PLATFORM=nixpkgs"
] ++ lib.optionals (msaClientID != null) [ "-DLauncher_MSA_CLIENT_ID=${msaClientID}" ] ] ++ lib.optionals (msaClientID != null) [ "-DLauncher_MSA_CLIENT_ID=${msaClientID}" ]
++ lib.optionals (lib.versionOlder qtbase.version "6") [ "-DLauncher_QT_VERSION_MAJOR=5" ]; ++ 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
@ -67,7 +104,7 @@ stdenv.mkDerivation rec {
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 = platforms.linux; platforms = with platforms; linux ++ darwin;
changelog = "https://github.com/PrismLauncher/PrismLauncher/releases/tag/${version}"; changelog = "https://github.com/PrismLauncher/PrismLauncher/releases/tag/${version}";
license = licenses.gpl3Only; license = licenses.gpl3Only;
maintainers = with maintainers; [ minion3665 Scrumplex getchoo ]; maintainers = with maintainers; [ minion3665 Scrumplex getchoo ];

View file

@ -16,7 +16,7 @@
, gamemode , gamemode
, msaClientID ? null , msaClientID ? null
, gamemodeSupport ? true , gamemodeSupport ? stdenv.isLinux
, jdks ? [ jdk17 jdk8 ] , jdks ? [ jdk17 jdk8 ]
, additionalLibs ? [ ] , additionalLibs ? [ ]
}: }:
@ -38,7 +38,7 @@ symlinkJoin {
qtbase qtbase
qtsvg qtsvg
] ]
++ lib.optional (lib.versionAtLeast qtbase.version "6") qtwayland; ++ lib.optional (lib.versionAtLeast qtbase.version "6" && stdenv.isLinux) qtwayland;
postBuild = '' postBuild = ''
wrapQtAppsHook wrapQtAppsHook
@ -64,9 +64,9 @@ symlinkJoin {
++ additionalLibs; ++ additionalLibs;
in in
[ [ "--prefix PRISMLAUNCHER_JAVA_PATHS : ${lib.makeSearchPath "bin/java" jdks}" ]
++ lib.optionals stdenv.isLinux [
"--set LD_LIBRARY_PATH /run/opengl-driver/lib:${lib.makeLibraryPath libs}" "--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 # xorg.xrandr needed for LWJGL [2.9.2, 3) https://github.com/LWJGL/lwjgl/issues/128
"--prefix PATH : ${lib.makeBinPath [xorg.xrandr]}" "--prefix PATH : ${lib.makeBinPath [xorg.xrandr]}"
]; ];

View file

@ -37747,11 +37747,15 @@ with pkgs;
principia = callPackage ../games/principia { }; principia = callPackage ../games/principia { };
prismlauncher-qt5-unwrapped = libsForQt5.callPackage ../games/prismlauncher { }; prismlauncher-qt5-unwrapped = libsForQt5.callPackage ../games/prismlauncher {
inherit (darwin.apple_sdk.frameworks) Cocoa;
};
prismlauncher-qt5 = libsForQt5.callPackage ../games/prismlauncher/wrapper.nix { prismlauncher-unwrapped = prismlauncher-qt5-unwrapped; }; prismlauncher-qt5 = libsForQt5.callPackage ../games/prismlauncher/wrapper.nix { prismlauncher-unwrapped = prismlauncher-qt5-unwrapped; };
prismlauncher-unwrapped = qt6Packages.callPackage ../games/prismlauncher { }; prismlauncher-unwrapped = qt6Packages.callPackage ../games/prismlauncher {
inherit (darwin.apple_sdk.frameworks) Cocoa;
};
prismlauncher = qt6Packages.callPackage ../games/prismlauncher/wrapper.nix { }; prismlauncher = qt6Packages.callPackage ../games/prismlauncher/wrapper.nix { };