diff --git a/pkgs/apps/games/polymc/default.nix b/pkgs/apps/games/polymc/default.nix new file mode 100644 index 0000000..0247ff7 --- /dev/null +++ b/pkgs/apps/games/polymc/default.nix @@ -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 diff --git a/pkgs/default.nix b/pkgs/default.nix index f15a2b0..b84c892 100644 --- a/pkgs/default.nix +++ b/pkgs/default.nix @@ -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; }; -} \ No newline at end of file + polymc = pkgs.qt6Packages.callPackage ./apps/games/polymc {}; + +}