refactor(nix): synchronize changes from nixpkgs

Signed-off-by: Sefa Eyeoglu <contact@scrumplex.net>
This commit is contained in:
Sefa Eyeoglu 2022-11-20 23:49:11 +01:00
parent 30607c34a1
commit f601135cc0
No known key found for this signature in database
GPG Key ID: C10411294912A422
2 changed files with 49 additions and 50 deletions

View File

@ -23,8 +23,8 @@
pkgs = forAllSystems (system: nixpkgs.legacyPackages.${system}); pkgs = forAllSystems (system: nixpkgs.legacyPackages.${system});
packagesFn = pkgs: rec { packagesFn = pkgs: rec {
prismlauncher = pkgs.libsForQt5.callPackage ./nix { inherit version self libnbtplusplus tomlplusplus; }; prismlauncher-qt5 = pkgs.libsForQt5.callPackage ./nix { inherit version self libnbtplusplus tomlplusplus; };
prismlauncher-qt6 = pkgs.qt6Packages.callPackage ./nix { inherit version self libnbtplusplus tomlplusplus; }; prismlauncher = pkgs.qt6Packages.callPackage ./nix { inherit version self libnbtplusplus tomlplusplus; };
}; };
in in
{ {

View File

@ -1,100 +1,99 @@
{ stdenv { lib
, lib , stdenv
, fetchFromGitHub
, cmake , cmake
, ninja
, jdk8 , jdk8
, jdk , jdk
, ghc_filesystem
, zlib , zlib
, file , file
, wrapQtAppsHook , wrapQtAppsHook
, xorg , xorg
, libpulseaudio , libpulseaudio
, qtbase , qtbase
, quazip , qtsvg
, qtwayland
, libGL , libGL
, msaClientID ? "" , quazip
, extraJDKs ? [ ] , glfw
, openal
, extra-cmake-modules , extra-cmake-modules
, ghc_filesystem
, msaClientID ? ""
, jdks ? [ jdk jdk8 ]
# flake # flake
, self , self
, version , version
, libnbtplusplus , libnbtplusplus
, tomlplusplus , tomlplusplus
, enableLTO ? false
}: }:
let
# Libraries required to run Minecraft
libpath = with xorg; lib.makeLibraryPath [
libX11
libXext
libXcursor
libXrandr
libXxf86vm
libpulseaudio
libGL
];
# This variable will be passed to Minecraft by Prism Launcher
gameLibraryPath = libpath + ":/run/opengl-driver/lib";
javaPaths = lib.makeSearchPath "bin/java" ([ jdk jdk8 ] ++ extraJDKs);
in
stdenv.mkDerivation rec { stdenv.mkDerivation rec {
pname = "prismlauncher"; pname = "prismlauncher";
inherit version; inherit version;
src = lib.cleanSource self; src = lib.cleanSource self;
nativeBuildInputs = [ cmake extra-cmake-modules ninja jdk ghc_filesystem file wrapQtAppsHook ]; nativeBuildInputs = [ extra-cmake-modules cmake file jdk wrapQtAppsHook ];
buildInputs = [ qtbase quazip zlib ]; buildInputs = [
qtbase
qtsvg
zlib
quazip
ghc_filesystem
] ++ lib.optional (lib.versionAtLeast qtbase.version "6") qtwayland;
cmakeFlags = lib.optionals (msaClientID != "") [ "-DLauncher_MSA_CLIENT_ID=${msaClientID}" ]
++ lib.optionals (lib.versionAtLeast qtbase.version "6") [ "-DLauncher_QT_VERSION_MAJOR=6" ];
dontWrapQtApps = true; dontWrapQtApps = true;
postUnpack = '' postUnpack = ''
# Copy libnbtplusplus
rm -rf source/libraries/libnbtplusplus rm -rf source/libraries/libnbtplusplus
mkdir 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 chmod -R +r+w source/libraries/libnbtplusplus
# Copy tomlplusplus chown -R $USER: source/libraries/libnbtplusplus
rm -rf source/libraries/tomlplusplus rm -rf source/libraries/tomlplusplus
mkdir source/libraries/tomlplusplus mkdir source/libraries/tomlplusplus
ln -s ${tomlplusplus}/* source/libraries/tomlplusplus ln -s ${tomlplusplus}/* source/libraries/tomlplusplus
chmod -R +r+w source/libraries/tomlplusplus chmod -R +r+w source/libraries/tomlplusplus
chown -R $USER: source/libraries/tomlplusplus
''; '';
cmakeFlags = [ postInstall =
"-GNinja" let
"-DLauncher_QT_VERSION_MAJOR=${lib.versions.major qtbase.version}" libpath = with xorg;
] ++ lib.optionals enableLTO [ "-DENABLE_LTO=on" ] lib.makeLibraryPath [
++ lib.optionals (msaClientID != "") [ "-DLauncher_MSA_CLIENT_ID=${msaClientID}" ]; libX11
libXext
# we have to check if the system is NixOS before adding stdenv.cc.cc.lib (#923) libXcursor
postInstall = '' libXrandr
libXxf86vm
libpulseaudio
libGL
glfw
openal
stdenv.cc.cc.lib
];
in
''
# 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
wrapQtApp $out/bin/prismlauncher \ wrapQtApp $out/bin/prismlauncher \
--run '[ -f /etc/NIXOS ] && export LD_LIBRARY_PATH="${stdenv.cc.cc.lib}/lib:$LD_LIBRARY_PATH"' \ --set LD_LIBRARY_PATH /run/opengl-driver/lib:${libpath} \
--prefix LD_LIBRARY_PATH : ${gameLibraryPath} \ --prefix PRISMLAUNCHER_JAVA_PATHS : ${lib.makeSearchPath "bin/java" jdks} \
--prefix PRISMLAUNCHER_JAVA_PATHS : ${javaPaths} \
--prefix PATH : ${lib.makeBinPath [xorg.xrandr]} --prefix PATH : ${lib.makeBinPath [xorg.xrandr]}
''; '';
meta = with lib; { meta = with lib; {
homepage = "https://prismlauncher.org/"; homepage = "https://prismlauncher.org/";
downloadPage = "https://prismlauncher.org/download/";
changelog = "https://github.com/PrismLauncher/PrismLauncher/releases";
description = "A free, open source launcher for Minecraft"; 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 = platforms.unix; platforms = platforms.linux;
changelog = "https://github.com/PrismLauncher/PrismLauncher/releases/tag/${version}";
license = licenses.gpl3Only; license = licenses.gpl3Only;
maintainers = with maintainers; [ minion3665 Scrumplex ]; maintainers = with maintainers; [ minion3665 Scrumplex ];
}; };