refactor(nix): introduce unwrapped packages

Signed-off-by: Sefa Eyeoglu <contact@scrumplex.net>
This commit is contained in:
Sefa Eyeoglu 2023-06-02 12:41:18 +02:00
parent acf1946dac
commit 0f0cbd4c1f
No known key found for this signature in database
GPG Key ID: E13DFD4B47127951
2 changed files with 17 additions and 50 deletions

View File

@ -6,13 +6,13 @@
}: { }: {
perSystem = {pkgs, ...}: { perSystem = {pkgs, ...}: {
packages = { packages = {
inherit (pkgs) prismlauncher prismlauncher-qt5; inherit (pkgs) prismlauncher-qt5-unwrapped prismlauncher-qt5 prismlauncher-unwrapped prismlauncher;
default = pkgs.prismlauncher; default = pkgs.prismlauncher;
}; };
}; };
flake = { flake = {
overlays.default = _: prev: let overlays.default = final: prev: let
# Helper function to build prism against different versions of Qt. # Helper function to build prism against different versions of Qt.
mkPrism = qt: mkPrism = qt:
qt.callPackage ./package.nix { qt.callPackage ./package.nix {
@ -20,8 +20,10 @@
inherit self version; inherit self version;
}; };
in { in {
prismlauncher = mkPrism prev.qt6Packages; prismlauncher-qt5-unwrapped = mkPrism final.libsForQt5;
prismlauncher-qt5 = mkPrism prev.libsForQt5; prismlauncher-qt5 = prev.prismlauncher-qt5.override {inherit (final) prismlauncher-unwrapped;};
prismlauncher-unwrapped = mkPrism final.qt6Packages;
prismlauncher = prev.prismlauncher.override {inherit (final) prismlauncher-unwrapped;};
}; };
}; };
} }

View File

@ -3,86 +3,51 @@
stdenv, stdenv,
cmake, cmake,
ninja, ninja,
jdk8,
jdk17, jdk17,
zlib, zlib,
file,
wrapQtAppsHook,
xorg,
libpulseaudio,
qtbase, qtbase,
qtsvg,
qtwayland,
libGL,
quazip, quazip,
glfw,
openal,
extra-cmake-modules, extra-cmake-modules,
tomlplusplus, tomlplusplus,
ghc_filesystem,
cmark, cmark,
msaClientID ? "", ghc_filesystem,
jdks ? [jdk17 jdk8],
gamemodeSupport ? true,
gamemode, gamemode,
# flake msaClientID ? null,
gamemodeSupport ? true,
self, self,
version, version,
libnbtplusplus, libnbtplusplus,
}: }:
stdenv.mkDerivation rec { stdenv.mkDerivation rec {
pname = "prismlauncher"; pname = "prismlauncher-unwrapped";
inherit version; inherit version;
src = lib.cleanSource self; src = lib.cleanSource self;
nativeBuildInputs = [extra-cmake-modules cmake file jdk17 ninja wrapQtAppsHook]; nativeBuildInputs = [extra-cmake-modules cmake jdk17 ninja];
buildInputs = buildInputs =
[ [
qtbase qtbase
qtsvg
zlib zlib
quazip quazip
ghc_filesystem ghc_filesystem
tomlplusplus tomlplusplus
cmark cmark
] ]
++ lib.optional (lib.versionAtLeast qtbase.version "6") qtwayland ++ lib.optional gamemodeSupport gamemode;
++ lib.optional gamemodeSupport gamemode.dev;
hardeningEnable = ["pie"];
cmakeFlags = cmakeFlags =
lib.optionals (msaClientID != "") ["-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"];
postUnpack = '' postUnpack = ''
rm -rf source/libraries/libnbtplusplus rm -rf source/libraries/libnbtplusplus
mkdir source/libraries/libnbtplusplus ln -s ${libnbtplusplus} source/libraries/libnbtplusplus
ln -s ${libnbtplusplus}/* source/libraries/libnbtplusplus
chmod -R +r+w source/libraries/libnbtplusplus
chown -R $USER: source/libraries/libnbtplusplus
''; '';
qtWrapperArgs = let dontWrapQtApps = true;
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]}"
];
meta = with lib; { meta = with lib; {
homepage = "https://prismlauncher.org/"; homepage = "https://prismlauncher.org/";