Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
173 changes: 173 additions & 0 deletions pkgs/by-name/po/polymc-unwrapped/package.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,173 @@
{
stdenv,
fetchFromGitHub,
Comment thread
MattSturgeon marked this conversation as resolved.
fetchurl,
lib,
cmake,
ninja,
jdk8,
gamemode,
mangohud,
zlib,
file,
qt6Packages,
kdePackages,
tomlplusplus,
ghc_filesystem,
msaClientID ? null,
msaRequired ? true,
gamemodeSupport ? stdenv.isLinux,
mangohudSupport ? stdenv.isLinux,
enableLTO ? false,
}:

/*
Feel free to override msaRequired to `false' on your machine, as
it's intended to NOT require an account to use the launcher.

It's set to true by default to avoid any piracy-related discussion.
*/

stdenv.mkDerivation (finalAttrs: {
pname = "polymc-unwrapped";
version = "7.0-unstable-2026-03-04";

libnbtplusplus = fetchFromGitHub {
owner = "PolyMC";
repo = "libnbtplusplus";
rev = "2203af7eeb48c45398139b583615134efd8d407f";
hash = "sha256-TvVOjkUobYJD9itQYueELJX3wmecvEdCbJ0FinW2mL4=";
};

/*
Gated so it only pulls when you're on Darwin.
Make sure the hash matches the one in CMakeLists!
*/

sparkle =
if stdenv.hostPlatform.isDarwin then
fetchurl {
url = "https://github.com/sparkle-project/Sparkle/releases/download/2.1.0/Sparkle-2.1.0.tar.xz";
hash = "sha256-v2rByqn40yHVeEhZyI2odPKEEvN/sye8IbexTF1h75Q=";
}
else
null;

src = fetchFromGitHub {
owner = "PolyMC";
repo = "PolyMC";
rev = "49e06691c47b6ed55f0306771c2dada301733b79";
hash = "sha256-K70TMZet+y4qPu0c8HZZDwuQIEhENP6XDjRzBptAiQI=";
};
Comment on lines +33 to +61

@MattSturgeon MattSturgeon May 30, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Future work: we'll probably want an update script to update these inputs in-sync.

Feel free to reach out on matrix or a draft PR or whatever if you want some help.


nativeBuildInputs = [
cmake
ninja
jdk8
file
];

buildInputs = [
qt6Packages.qtbase
qt6Packages.quazip
qt6Packages.qtcharts
zlib

tomlplusplus
ghc_filesystem
kdePackages.extra-cmake-modules
]
++ lib.optionals stdenv.hostPlatform.isLinux [
qt6Packages.qtwayland
qt6Packages.qt6ct
]
++ lib.optional gamemodeSupport gamemode;
Comment thread
MattSturgeon marked this conversation as resolved.

dontWrapQtApps = true;
doCheck = true;
strictDeps = true;
__structuredAttrs = true;

postUnpack = ''
rm -rf source/libraries/libnbtplusplus
ln -s ${finalAttrs.libnbtplusplus} source/libraries/libnbtplusplus
'';

substituteBuildConfigCppFlags = [
"--replace-fail"
"return vstr;"
"return vstr + \"+NixOS\";"
]
++ lib.optionals ((finalAttrs.src.rev or null) != null) [
"--replace-fail"
"@Launcher_GIT_COMMIT@"
finalAttrs.src.rev
]
++ lib.optionals ((finalAttrs.src.tag or null) != null) [
"--replace-fail"
"@Launcher_GIT_TAG@"
finalAttrs.src.tag
]
++ lib.optionals ((finalAttrs.src.ref or null) != null) [
"--replace-fail"
"@Launcher_GIT_REFSPEC@"
finalAttrs.src.ref
];

# This is for metadata & branding.
postPatch = ''
if [ ''${#substituteBuildConfigCppFlags[@]} -gt 0 ]; then
substituteInPlace buildconfig/BuildConfig.cpp.in "''${substituteBuildConfigCppFlags[@]}"
fi
''
# APPLE branch hardcodes INSTALL_BUNDLE=full (bundles Qt via fixup_bundle,
# conflicting with nixpkgs' wrapped Qt); force nodeps.
+ lib.optionalString stdenv.hostPlatform.isDarwin ''
substituteInPlace CMakeLists.txt \
--replace-fail 'set(INSTALL_BUNDLE "full")' 'set(INSTALL_BUNDLE "nodeps")'
'';

cmakeFlags = [
(lib.cmakeFeature "Launcher_QT_VERSION_MAJOR" (lib.versions.major qt6Packages.qtbase.version))
(lib.cmakeFeature "Launcher_BUILD_PLATFORM" "nixpkgs")
(lib.cmakeBool "ENABLE_LTO" enableLTO)
(lib.cmakeBool "Launcher_STRICT_DRM" msaRequired)
]
++ lib.optional (msaClientID != null) (lib.cmakeFeature "Launcher_MSA_CLIENT_ID" msaClientID)
++ lib.optionals stdenv.hostPlatform.isDarwin [
# Inert auto-updater feed; source Sparkle from the vendored copy.
(lib.cmakeFeature "MACOSX_SPARKLE_UPDATE_FEED_URL" "")
(lib.cmakeFeature "MACOSX_SPARKLE_DOWNLOAD_URL" "file://${finalAttrs.sparkle}")
(lib.cmakeFeature "CMAKE_INSTALL_PREFIX" "${placeholder "out"}/Applications/")
];
Comment thread
MattSturgeon marked this conversation as resolved.

meta = {
homepage = "https://polymc.org/";
downloadPage = "https://polymc.org/download/";
changelog =
"https://github.com/PolyMC/PolyMC/releases"
+ lib.optionalString ((finalAttrs.src.tag or null) != null) "/tag/${finalAttrs.src.tag}";
description = "A free, open source launcher for Minecraft";
longDescription = ''
Allows you to have and manage multiple, separate instances of Minecraft with a simple interface.
The contents of each instance are separate. That includes mods, texture packs, saves, etc.
'';
problems =
lib.optionalAttrs (!stdenv.hostPlatform.isLinux && gamemodeSupport) {
broken.message = "${gamemode.pname} is only supported on Linux.";
}
// lib.optionalAttrs (!stdenv.hostPlatform.isLinux && mangohudSupport) {
broken.message = "${mangohud.pname} is only supported on Linux.";
};
platforms = [
"x86_64-freebsd"
]
Comment thread
MattSturgeon marked this conversation as resolved.
++ lib.platforms.linux
++ lib.platforms.darwin

@MattSturgeon MattSturgeon May 30, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interestingly, CI is seeing this as zero rebuilds on darwin...

(Just an observation, not review feedback)

cc @NixOS/nixpkgs-ci is this a bug on our end?

EDIT: not a CI bug, see below. But maybe CI could be clearer about eval failures?

++ lib.platforms.windows;
license = lib.licenses.gpl3Only;
maintainers = with lib.maintainers; [
hustlerone
];
};
})
144 changes: 144 additions & 0 deletions pkgs/by-name/po/polymc/package.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
{
stdenv,
lib,
symlinkJoin,
addDriverRunpath,

msaClientID ? null,
msaRequired ? true,
enableLTO ? false,
gamemodeSupport ? stdenv.isLinux,
Comment thread
MattSturgeon marked this conversation as resolved.
mangohudSupport ? stdenv.isLinux,

jdks ? [
jdk25
jdk21
jdk17
jdk8
],
jdk25,
jdk21,
jdk17,
jdk8,

additionalLibraries ? [ ],
additionalBinaries ? [ ],

polymc-unwrapped,
qt6,
mesa-demos,
gamemode,
mangohud,

libx11,
libxext,
libxcursor,
libxrandr,
libxxf86vm,
xrandr,

libpulseaudio,
libGL,
glfw,
openal,
udev,
wayland,
vulkan-loader,
}:

/*
Feel free to override msaRequired to `false' on your machine, as
it's intended to NOT require an account to use the launcher.

It's set to true by default to avoid any piracy-related discussion.
*/

let
polymc = polymc-unwrapped.override {
inherit
msaClientID
msaRequired
gamemodeSupport
enableLTO
;
};
in
symlinkJoin {
name = "polymc";
inherit (polymc) version;

paths = [ polymc ];
nativeBuildInputs = [ qt6.wrapQtAppsHook ];
buildInputs = with qt6; [
qtbase
qtwayland
];

postBuild = "wrapQtAppsHook";

strictDeps = true;
__structuredAttrs = true;

qtWrapperArgs =
let
runtimeLibs = [
# xorg
libx11
libxext
libxcursor
libxrandr
libxxf86vm

libpulseaudio
libGL
glfw
openal
stdenv.cc.cc.lib

vulkan-loader # VulkanMod's lwjgl
]
++ additionalLibraries
++ lib.optionals stdenv.hostPlatform.isLinux [
wayland
udev # OSHI
]
++ lib.optional gamemodeSupport gamemode.lib;

runtimeBins = [
xrandr # Required by old LWJGL versions
mesa-demos # For glxinfo
]
++ additionalBinaries;
in
Comment thread
MattSturgeon marked this conversation as resolved.
[
"--prefix"
"POLYMC_JAVA_PATHS"
":"
(lib.makeSearchPath "bin/java" jdks)
]

++ lib.optionals stdenv.hostPlatform.isLinux [
"--set"
"LD_LIBRARY_PATH"
"${addDriverRunpath.driverLink}/lib:${lib.makeLibraryPath runtimeLibs}${
if mangohudSupport then ":${mangohud}/lib/mangohud" else ""
}"
"--prefix"
"PATH"
":"
(lib.makeBinPath runtimeBins)
];

meta = {
inherit (polymc.meta)
homepage
downloadPage
changelog
description
longDescription
platforms
license
maintainers
;
};
}
Loading