Update Nix package

- Updated Nix flake. This fixes theming, which was broken on newer
  systems due to a version mismatch.
- Added xrandr to the path inside the wrapped binary. Xrandr is required
  by older LWJGL versions. This allows launching old MC versions without
  a system Xrandr installation.
- Added options to the wrapped package that allow for the user to add
  additonal libraries or binaries.
- Added support for libgamemode
- Set BUILD_PLATFORM to nix to make nix builds identifiable
This commit is contained in:
LordMZTE 2024-07-30 21:24:28 +02:00
parent 4f5422e069
commit 3f4de323b4
No known key found for this signature in database
GPG Key ID: B64802DC33A64FF6
3 changed files with 30 additions and 11 deletions

View File

@ -34,11 +34,11 @@
}, },
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1712129508, "lastModified": 1722141560,
"narHash": "sha256-FBVpEX0eLiqX3jnSL3rmJHqHhbuCikJZyDyV3Cl3qAY=", "narHash": "sha256-Ul3rIdesWaiW56PS/Ak3UlJdkwBrD4UcagCmXZR9Z7Y=",
"owner": "nixos", "owner": "nixos",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "d03a4482228d4d6dbd2d4b425b6dfcd49ebe765f", "rev": "038fb464fcfa79b4f08131b07f2d8c9a6bcc4160",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -59,11 +59,11 @@
"tomlplusplus": { "tomlplusplus": {
"flake": false, "flake": false,
"locked": { "locked": {
"lastModified": 1710824845, "lastModified": 1720775063,
"narHash": "sha256-A9XuCfVcLle/tMNaH7aqb1leM+t3wwC9ER5RIbMMovo=", "narHash": "sha256-9j8qNCITFPvKECY5Sjb2Ri5KcPzRrF0e7G2CUemIhBw=",
"owner": "marzer", "owner": "marzer",
"repo": "tomlplusplus", "repo": "tomlplusplus",
"rev": "1f7884e59165e517462f922e7b6de131bd9844f3", "rev": "e2bae9d559b4956a831fcef10ac8f01c88cb0d13",
"type": "github" "type": "github"
}, },
"original": { "original": {

View File

@ -8,6 +8,8 @@
, jdk17 , jdk17
, jdk21 , jdk21
, xorg , xorg
, gamemode
, glxinfo
, libpulseaudio , libpulseaudio
, qtbase , qtbase
, libGL , libGL
@ -19,13 +21,16 @@
, msaClientID ? "" , msaClientID ? ""
, jdks ? [ jdk21 jdk17 jdk8 ] , jdks ? [ jdk21 jdk17 jdk8 ]
, enableLTO ? false , enableLTO ? false
, gamemodeSupport ? stdenv.isLinux
, additionalLibs ? [ ]
, additionalBins ? [ ]
, self , self
, version , version
# flake # flake
}: }:
let let
polymcInner = polymc-unwrapped.override { inherit msaClientID enableLTO; }; polymcInner = polymc-unwrapped.override { inherit msaClientID enableLTO gamemodeSupport; };
in in
symlinkJoin { symlinkJoin {
@ -59,12 +64,21 @@ symlinkJoin {
stdenv.cc.cc.lib stdenv.cc.cc.lib
udev # OSHI udev # OSHI
wayland wayland
]; ]
++ lib.optional gamemodeSupport gamemode.lib
++ additionalLibs;
runtimeBins = [
# Required by old LWJGL versions
xorg.xrandr
glxinfo
] ++ additionalBins;
in in
[ [
"--prefix POLYMC_JAVA_PATHS : ${lib.makeSearchPath "bin/java" jdks}" "--prefix POLYMC_JAVA_PATHS : ${lib.makeSearchPath "bin/java" jdks}"
"--set LD_LIBRARY_PATH ${addOpenGLRunpath.driverLink}/lib:${lib.makeLibraryPath runtimeLibs}" "--set LD_LIBRARY_PATH ${addOpenGLRunpath.driverLink}/lib:${lib.makeLibraryPath runtimeLibs}"
"--prefix PATH : ${lib.makeBinPath runtimeBins}"
]; ];
inherit (polymcInner) meta; inherit (polymcInner) meta;
} }

View File

@ -3,12 +3,12 @@
, cmake , cmake
, ninja , ninja
, jdk8 , jdk8
, gamemode
, ghc_filesystem , ghc_filesystem
, zlib , zlib
, file , file
, qtbase , qtbase
, quazip , quazip
, msaClientID ? ""
, extra-cmake-modules , extra-cmake-modules
, qtcharts , qtcharts
, qtwayland , qtwayland
@ -17,6 +17,8 @@
, version , version
, libnbtplusplus , libnbtplusplus
, tomlplusplus , tomlplusplus
, msaClientID ? ""
, gamemodeSupport ? stdenv.isLinux
, enableLTO ? false , enableLTO ? false
}: }:
@ -27,7 +29,9 @@ stdenv.mkDerivation {
src = lib.cleanSource self; src = lib.cleanSource self;
nativeBuildInputs = [ cmake extra-cmake-modules ninja jdk8 ghc_filesystem file ]; nativeBuildInputs = [ cmake extra-cmake-modules ninja jdk8 ghc_filesystem file ];
buildInputs = [ qtbase quazip zlib qtcharts ] ++ lib.optional (lib.versionAtLeast qtbase.version "6") qtwayland; buildInputs = [ qtbase quazip zlib qtcharts ]
++ lib.optional (lib.versionAtLeast qtbase.version "6") qtwayland
++ lib.optional gamemodeSupport gamemode;
postUnpack = '' postUnpack = ''
# Copy libnbtplusplus # Copy libnbtplusplus
@ -47,6 +51,7 @@ stdenv.mkDerivation {
cmakeFlags = [ cmakeFlags = [
"-GNinja" "-GNinja"
"-DLauncher_QT_VERSION_MAJOR=${lib.versions.major qtbase.version}" "-DLauncher_QT_VERSION_MAJOR=${lib.versions.major qtbase.version}"
"-DLauncher_BUILD_PLATFORM=nix"
] ]
++ lib.optionals enableLTO [ "-DENABLE_LTO=on" ] ++ lib.optionals enableLTO [ "-DENABLE_LTO=on" ]
++ lib.optionals (msaClientID != "") [ "-DLauncher_MSA_CLIENT_ID=${msaClientID}" ]; ++ lib.optionals (msaClientID != "") [ "-DLauncher_MSA_CLIENT_ID=${msaClientID}" ];