polymc: Init package

This commit is contained in:
Mateusz Słodkowicz 2023-05-23 02:11:55 +02:00
parent c8efd18a3a
commit 29ede6c65d
Signed by: materus
GPG Key ID: 28D140BCA60B4FD1
2 changed files with 141 additions and 11 deletions

View File

@ -0,0 +1,126 @@
{ stdenv
, lib
, fetchFromGitHub
, cmake
, ninja
, jdk8
, jdk
, ghc_filesystem
, zlib
, file
, wrapQtAppsHook
, xorg
, libpulseaudio
, qtbase
, quazip
, libGL
, msaClientID ? ""
, extra-cmake-modules
, qtcharts
# For wrapper
, makeWrapper
}:
let polymc =
let
libpath = with xorg; lib.makeLibraryPath ([
libX11
libXext
libXcursor
libXrandr
libXxf86vm
libpulseaudio
libGL
]);
gameLibraryPath = libpath + ":/run/opengl-driver/lib";
in
stdenv.mkDerivation rec {
pname = "polymc";
version = "5.1";
src = fetchFromGitHub {
owner = "PolyMC";
repo = "PolyMC";
rev = version;
sha256 = "sha256-D7OYzuvrigtmbk3Apqf29v2bTMgmlDZKFYOx71isVRM=";
fetchSubmodules = true;
};
dontWrapQtApps = true;
nativeBuildInputs = [ cmake extra-cmake-modules ninja jdk ghc_filesystem file wrapQtAppsHook ];
buildInputs = [ qtbase quazip zlib qtcharts ];
cmakeFlags = [
"-GNinja"
"-DLauncher_QT_VERSION_MAJOR=${lib.versions.major qtbase.version}"
] ++ lib.optionals (msaClientID != "") [ "-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("/usr/lib32/jvm")' 'javas.append("${jdk8}/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 \
--prefix LD_LIBRARY_PATH : "${gameLibraryPath}" \
--prefix PATH : "${lib.makeBinPath ([ xorg.xrandr ]) }"
'';
passthru = {
wrap =
{ extraJDKs ? [ ]
, extraPaths ? [ ]
, extraLibs ? [ ]
}: stdenv.mkDerivation rec {
pname = "polymc-wrapped";
version = polymc.version;
src = polymc;
nativeBuildInputs = [ makeWrapper ];
phases = [ "installPhase" "fixupPhase" ];
installPhase = ''
mkdir -p $out/bin
ln -s $src/bin/polymc $out/bin/polymc
'';
postFixup = let javaPaths = lib.makeSearchPath "bin/java" (extraJDKs); in
''
wrapProgram $out/bin/polymc \
--prefix LD_LIBRARY_PATH : "${lib.makeLibraryPath extraLibs}" \
--prefix POLYMC_JAVA_PATHS : "${javaPaths}" \
--prefix PATH : "${lib.makeBinPath extraPaths}"
'';
preferLocalBuild = true;
meta = polymc.meta;
};
};
meta = with lib; {
homepage = "https://polymc.org/";
downloadPage = "https://polymc.org/download/";
changelog = "https://github.com/PolyMC/PolyMC/releases";
description = "A free, open source launcher for Minecraft";
longDescription = ''
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 associated options with a simple interface.
'';
platforms = [ "x86_64-linux" ];
license = licenses.gpl3Only;
};
};
in
polymc

View File

@ -1,17 +1,21 @@
{pkgs, callPackage}:
{ pkgs, callPackage }:
rec {
amdgpu-pro-libs = pkgs.lib.recurseIntoAttrs {
vulkan = callPackage ./libs/amdgpu-pro-libs { };
amf = callPackage ./libs/amdgpu-pro-libs/amf.nix { };
opengl = callPackage ./libs/amdgpu-pro-libs/opengl.nix { };
prefixes = callPackage ./libs/amdgpu-pro-libs/prefixes.nix { };
};
amdgpu-pro-libs = pkgs.lib.recurseIntoAttrs {
vulkan = callPackage ./libs/amdgpu-pro-libs { };
amf = callPackage ./libs/amdgpu-pro-libs/amf.nix { };
opengl = callPackage ./libs/amdgpu-pro-libs/opengl.nix { };
prefixes = callPackage ./libs/amdgpu-pro-libs/prefixes.nix { };
};
ffmpeg6-amf-full = pkgs.callPackage ./apps/ffmpeg {inherit (pkgs.darwin.apple_sdk.frameworks)
ffmpeg6-amf-full = pkgs.callPackage ./apps/ffmpeg {
inherit (pkgs.darwin.apple_sdk.frameworks)
Cocoa CoreServices CoreAudio CoreMedia AVFoundation MediaToolbox
VideoDecodeAcceleration VideoToolbox;};
VideoDecodeAcceleration VideoToolbox;
};
obs-amf = pkgs.qt6Packages.callPackage ./apps/obs { ffmpeg = ffmpeg6-amf-full;};
obs-amf = pkgs.qt6Packages.callPackage ./apps/obs { ffmpeg = ffmpeg6-amf-full; };
}
polymc = pkgs.qt6Packages.callPackage ./apps/games/polymc {};
}