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, ...}: {
packages = {
inherit (pkgs) prismlauncher prismlauncher-qt5;
inherit (pkgs) prismlauncher-qt5-unwrapped prismlauncher-qt5 prismlauncher-unwrapped prismlauncher;
default = pkgs.prismlauncher;
};
};
flake = {
overlays.default = _: prev: let
overlays.default = final: prev: let
# Helper function to build prism against different versions of Qt.
mkPrism = qt:
qt.callPackage ./package.nix {
@ -20,8 +20,10 @@
inherit self version;
};
in {
prismlauncher = mkPrism prev.qt6Packages;
prismlauncher-qt5 = mkPrism prev.libsForQt5;
prismlauncher-qt5-unwrapped = mkPrism final.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,
cmake,
ninja,
jdk8,
jdk17,
zlib,
file,
wrapQtAppsHook,
xorg,
libpulseaudio,
qtbase,
qtsvg,
qtwayland,
libGL,
quazip,
glfw,
openal,
extra-cmake-modules,
tomlplusplus,
ghc_filesystem,
cmark,
msaClientID ? "",
jdks ? [jdk17 jdk8],
gamemodeSupport ? true,
ghc_filesystem,
gamemode,
# flake
msaClientID ? null,
gamemodeSupport ? true,
self,
version,
libnbtplusplus,
}:
stdenv.mkDerivation rec {
pname = "prismlauncher";
pname = "prismlauncher-unwrapped";
inherit version;
src = lib.cleanSource self;
nativeBuildInputs = [extra-cmake-modules cmake file jdk17 ninja wrapQtAppsHook];
nativeBuildInputs = [extra-cmake-modules cmake jdk17 ninja];
buildInputs =
[
qtbase
qtsvg
zlib
quazip
ghc_filesystem
tomlplusplus
cmark
]
++ lib.optional (lib.versionAtLeast qtbase.version "6") qtwayland
++ lib.optional gamemodeSupport gamemode.dev;
++ lib.optional gamemodeSupport gamemode;
hardeningEnable = ["pie"];
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"];
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
'';
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/";