mirror of https://github.com/materusPL/Nixerus.git
polymc: Formatting, fix gamemode/mangohud, use tomlplusplus from nixpkgs
This commit is contained in:
parent
b148d7e059
commit
a168213719
|
@ -1,85 +1,97 @@
|
|||
{ stdenv
|
||||
, fetchurl
|
||||
, lib
|
||||
, fetchFromGitHub
|
||||
, cmake
|
||||
, ninja
|
||||
, jdk
|
||||
, ghc_filesystem
|
||||
, zlib
|
||||
, file
|
||||
, wrapQtAppsHook
|
||||
, xorg
|
||||
, libpulseaudio
|
||||
, openal
|
||||
, qtbase
|
||||
, qtwayland
|
||||
, qtsvg
|
||||
, glfw
|
||||
, pciutils
|
||||
, udev
|
||||
, glxinfo
|
||||
, quazip
|
||||
, libGL
|
||||
, flite
|
||||
, addDriverRunpath
|
||||
, vulkan-loader
|
||||
, msaClientID ? null
|
||||
, extra-cmake-modules
|
||||
, qtcharts
|
||||
, makeWrapper
|
||||
, gamemode
|
||||
, mangohud
|
||||
, glfw-wayland-minecraft
|
||||
, writeShellScript
|
||||
{
|
||||
stdenv,
|
||||
fetchurl,
|
||||
lib,
|
||||
fetchFromGitHub,
|
||||
cmake,
|
||||
ninja,
|
||||
jdk,
|
||||
ghc_filesystem,
|
||||
zlib,
|
||||
file,
|
||||
wrapQtAppsHook,
|
||||
xorg,
|
||||
libpulseaudio,
|
||||
openal,
|
||||
qtbase,
|
||||
qtwayland,
|
||||
qtsvg,
|
||||
glfw3-minecraft,
|
||||
pciutils,
|
||||
udev,
|
||||
glxinfo,
|
||||
quazip,
|
||||
libGL,
|
||||
flite,
|
||||
tomlplusplus,
|
||||
addDriverRunpath,
|
||||
vulkan-loader,
|
||||
msaClientID ? null,
|
||||
extra-cmake-modules,
|
||||
qtcharts,
|
||||
makeWrapper,
|
||||
gamemode,
|
||||
mangohud,
|
||||
strictDrm ? false,
|
||||
}:
|
||||
|
||||
|
||||
|
||||
let
|
||||
polymc =
|
||||
let
|
||||
binpath = lib.makeBinPath ([ xorg.xrandr glxinfo pciutils ]);
|
||||
|
||||
libpath = with xorg; lib.makeLibraryPath ([
|
||||
libX11
|
||||
libXext
|
||||
libXcursor
|
||||
libXrandr
|
||||
libXxf86vm
|
||||
libpulseaudio
|
||||
libGL
|
||||
vulkan-loader
|
||||
glfw
|
||||
openal
|
||||
udev
|
||||
flite
|
||||
stdenv.cc.cc.lib
|
||||
]);
|
||||
|
||||
binpath = lib.makeBinPath [
|
||||
xorg.xrandr
|
||||
glxinfo
|
||||
pciutils
|
||||
];
|
||||
libpath =
|
||||
with xorg;
|
||||
lib.makeLibraryPath [
|
||||
glfw3-minecraft
|
||||
libX11
|
||||
libXext
|
||||
libXcursor
|
||||
libXrandr
|
||||
libXxf86vm
|
||||
|
||||
libGL
|
||||
vulkan-loader
|
||||
|
||||
openal
|
||||
libpulseaudio
|
||||
udev
|
||||
flite
|
||||
stdenv.cc.cc.lib
|
||||
];
|
||||
gameLibraryPath = libpath + ":${addDriverRunpath.driverLink}/lib";
|
||||
|
||||
|
||||
in
|
||||
stdenv.mkDerivation rec {
|
||||
pname = "polymc" + (lib.optionalString ((lib.versions.major qtbase.version) == "5") "-qt5");
|
||||
version = "7.0";
|
||||
|
||||
|
||||
patches = [
|
||||
# Fix for Qt >= 6.9.0
|
||||
(fetchurl {
|
||||
(fetchurl {
|
||||
url = "https://github.com/PolyMC/PolyMC/commit/0dc124d636d76692b1e2c01050743dd87dc78a05.patch";
|
||||
hash = "sha256-ACrS7JAcLq46f8puQlfvPlRb6vk/+wuv+y1yqGQjp/I=";
|
||||
})
|
||||
];
|
||||
|
||||
libnbtplusplus = fetchFromGitHub {
|
||||
owner = "PolyMC";
|
||||
repo = "libnbtplusplus";
|
||||
rev = "2203af7eeb48c45398139b583615134efd8d407f";
|
||||
hash = "sha256-TvVOjkUobYJD9itQYueELJX3wmecvEdCbJ0FinW2mL4=";
|
||||
};
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "PolyMC";
|
||||
repo = "PolyMC";
|
||||
rev = version;
|
||||
sha256 = "sha256-tJA/xSfqRXZK/OXbxhLNqUJU5nQGVzxgownXUMTy284=";
|
||||
fetchSubmodules = true;
|
||||
};
|
||||
postUnpack = ''
|
||||
rm -rf source/libraries/libnbtplusplus
|
||||
ln -s ${libnbtplusplus} source/libraries/libnbtplusplus
|
||||
'';
|
||||
dontWrapQtApps = true;
|
||||
nativeBuildInputs = [
|
||||
cmake
|
||||
|
@ -96,25 +108,23 @@ let
|
|||
qtcharts
|
||||
qtwayland
|
||||
quazip
|
||||
tomlplusplus
|
||||
zlib
|
||||
];
|
||||
|
||||
|
||||
cmakeFlags = [
|
||||
"-GNinja"
|
||||
"-DLauncher_QT_VERSION_MAJOR=${lib.versions.major qtbase.version}"
|
||||
]
|
||||
++ lib.optionals (msaClientID != null) [ "-DLauncher_MSA_CLIENT_ID=${msaClientID}" ];
|
||||
|
||||
(lib.cmakeFeature "Launcher_BUILD_PLATFORM" "nixerus")
|
||||
(lib.cmakeFeature "Launcher_QT_VERSION_MAJOR" (lib.versions.major qtbase.version))
|
||||
(lib.cmakeBool "Launcher_STRICT_DRM" strictDrm)
|
||||
] ++ lib.optionals (msaClientID != null) [ "-DLauncher_MSA_CLIENT_ID=${msaClientID}" ];
|
||||
|
||||
postPatch = ''
|
||||
# hardcode jdk paths
|
||||
substituteInPlace launcher/java/JavaUtils.cpp \
|
||||
--replace 'scanJavaDir("/usr/lib/jvm")' 'javas.append("${jdk}/lib/openjdk/bin/java")'
|
||||
--replace 'scanJavaDir("/app/jdk");' 'scanJavaDir("/app/jdk"); javas.append("${jdk}/lib/openjdk/bin/java");'
|
||||
'';
|
||||
|
||||
postFixup = ''
|
||||
# xorg.xrandr needed for LWJGL [2.9.2, 3) https://github.com/LWJGL/lwjgl/issues/128
|
||||
wrapQtApp $out/bin/polymc \
|
||||
--suffix LD_LIBRARY_PATH : "${gameLibraryPath}" \
|
||||
--suffix PATH : "${binpath}" \
|
||||
|
@ -122,41 +132,43 @@ let
|
|||
'';
|
||||
passthru = {
|
||||
|
||||
|
||||
wrap =
|
||||
{ extraJDKs ? [ ]
|
||||
, extraPaths ? [ ]
|
||||
, extraLibs ? [ ]
|
||||
, withWaylandGLFW ? false
|
||||
, withMangohud ? true
|
||||
, withGamemode ? true
|
||||
}: stdenv.mkDerivation rec {
|
||||
{
|
||||
extraJDKs ? [ ],
|
||||
extraPaths ? [ ],
|
||||
extraLibs ? [ ],
|
||||
withMangohud ? true,
|
||||
withGamemode ? true,
|
||||
}:
|
||||
stdenv.mkDerivation rec {
|
||||
pname = "${polymc.pname}-wrapped";
|
||||
version = polymc.version;
|
||||
libsPath = (lib.makeLibraryPath (extraLibs ++ lib.optional withGamemode gamemode.lib)) + lib.optionalString withMangohud "${mangohud + "/lib/mangohud"}";
|
||||
libsPath =
|
||||
(lib.makeLibraryPath (extraLibs ++ lib.optional withGamemode gamemode.lib))
|
||||
+ lib.optionalString withMangohud ":${mangohud + "/lib/mangohud"}";
|
||||
binsPath = lib.makeBinPath (extraPaths ++ lib.optional withMangohud mangohud);
|
||||
|
||||
waylandPreExec = writeShellScript "waylandGLFW" ''
|
||||
if [ -n "$WAYLAND_DISPLAY" ]; then
|
||||
export LD_LIBRARY_PATH=${lib.getLib glfw-wayland-minecraft}/lib:"$LD_LIBRARY_PATH"
|
||||
fi
|
||||
'';
|
||||
src = polymc;
|
||||
nativeBuildInputs = [ makeWrapper ];
|
||||
phases = [ "installPhase" "fixupPhase" ];
|
||||
phases = [
|
||||
"installPhase"
|
||||
"fixupPhase"
|
||||
];
|
||||
installPhase = ''
|
||||
mkdir -p $out/bin
|
||||
ln -s $src/bin/polymc $out/bin/polymc
|
||||
ln -s $src/share $out/share
|
||||
'';
|
||||
|
||||
postFixup = let javaPaths = lib.makeSearchPath "bin/java" (extraJDKs); in
|
||||
postFixup =
|
||||
let
|
||||
javaPaths = lib.makeSearchPath "bin/java" extraJDKs;
|
||||
in
|
||||
''
|
||||
wrapProgram $out/bin/polymc \
|
||||
--suffix LD_LIBRARY_PATH : "${libsPath}" \
|
||||
--suffix POLYMC_JAVA_PATHS : "${javaPaths}" \
|
||||
--suffix PATH : "${binsPath}" ${lib.optionalString withWaylandGLFW ''--run ${waylandPreExec}''}
|
||||
|
||||
--prefix LD_LIBRARY_PATH : "${libsPath}" \
|
||||
--prefix POLYMC_JAVA_PATHS : "${javaPaths}" \
|
||||
--prefix PATH : "${binsPath}"
|
||||
'';
|
||||
|
||||
preferLocalBuild = true;
|
||||
|
|
Loading…
Reference in New Issue