Merge pull request #1649 from LordMZTE/nix-fix

fix nix build
This commit is contained in:
Lenny McLennington 2024-04-22 09:05:08 +01:00 committed by GitHub
commit d9760a16f5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 125 additions and 89 deletions

View File

@ -3,11 +3,11 @@
"flake-compat": {
"flake": false,
"locked": {
"lastModified": 1650374568,
"narHash": "sha256-Z+s0J8/r907g149rllvwhb4pKi8Wam5ij0st8PwAh+E=",
"lastModified": 1696426674,
"narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=",
"owner": "edolstra",
"repo": "flake-compat",
"rev": "b4a34015c698c7793d592d66adbab377907a2be8",
"rev": "0f9255e01c2351cc7d116c072cb317785dd33b33",
"type": "github"
},
"original": {
@ -34,11 +34,11 @@
},
"nixpkgs": {
"locked": {
"lastModified": 1658119717,
"narHash": "sha256-4upOZIQQ7Bc4CprqnHsKnqYfw+arJeAuU+QcpjYBXW0=",
"lastModified": 1712129508,
"narHash": "sha256-FBVpEX0eLiqX3jnSL3rmJHqHhbuCikJZyDyV3Cl3qAY=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "9eb60f25aff0d2218c848dd4574a0ab5e296cabe",
"rev": "d03a4482228d4d6dbd2d4b425b6dfcd49ebe765f",
"type": "github"
},
"original": {
@ -59,11 +59,11 @@
"tomlplusplus": {
"flake": false,
"locked": {
"lastModified": 1664034574,
"narHash": "sha256-EFMAl6tsTvkgK0DWC/pZfOIq06b2e5SnxJa1ngGRIQA=",
"lastModified": 1710824845,
"narHash": "sha256-A9XuCfVcLle/tMNaH7aqb1leM+t3wwC9ER5RIbMMovo=",
"owner": "marzer",
"repo": "tomlplusplus",
"rev": "8aa5c8b2a4ff2c440d4630addf64fa4f62146170",
"rev": "1f7884e59165e517462f922e7b6de131bd9844f3",
"type": "github"
},
"original": {

View File

@ -23,8 +23,11 @@
pkgs = forAllSystems (system: nixpkgs.legacyPackages.${system});
packagesFn = pkgs: rec {
polymc = pkgs.libsForQt5.callPackage ./nix { inherit version self libnbtplusplus tomlplusplus; };
polymc-qt6 = pkgs.qt6Packages.callPackage ./nix { inherit version self libnbtplusplus tomlplusplus; };
polymc-unwrapped = pkgs.qt6Packages.callPackage ./nix/unwrapped.nix { inherit version self libnbtplusplus tomlplusplus; };
polymc-qt5-unwrapped = pkgs.libsForQt5.callPackage ./nix/unwrapped.nix { inherit version self libnbtplusplus tomlplusplus; };
polymc = pkgs.qt6Packages.callPackage ./nix { inherit version self polymc-unwrapped; };
polymc-qt5 = pkgs.libsForQt5.callPackage ./nix { inherit version self; polymc-unwrapped = polymc-qt5-unwrapped; };
default = polymc;
};
in
{
@ -33,6 +36,6 @@
packages // { default = packages.polymc; }
);
overlay = final: packagesFn;
overlay = final: prev: packagesFn final;
};
}

View File

@ -1,101 +1,66 @@
{ stdenv
, lib
, fetchFromGitHub
, cmake
, ninja
, jdk8
, jdk
, ghc_filesystem
, zlib
, file
, symlinkJoin
, addOpenGLRunpath
, polymc-unwrapped
, wrapQtAppsHook
, jdk8
, jdk17
, xorg
, libpulseaudio
, qtbase
, quazip
, libGL
, glfw
, openal
, udev
, msaClientID ? ""
, extraJDKs ? [ ]
, extra-cmake-modules
, qtcharts
, jdks ? [ jdk17 jdk8 ]
, enableLTO ? false
# flake
, self
, version
, libnbtplusplus
, tomlplusplus
, enableLTO ? false
}:
let
# Libraries required to run Minecraft
libpath = with xorg; lib.makeLibraryPath [
libX11
libXext
libXcursor
libXrandr
libXxf86vm
libpulseaudio
libGL
];
# This variable will be passed to Minecraft by PolyMC
gameLibraryPath = libpath + ":/run/opengl-driver/lib";
javaPaths = lib.makeSearchPath "bin/java" ([ jdk jdk8 ] ++ extraJDKs);
polymcInner = polymc-unwrapped.override { inherit msaClientID enableLTO; };
in
stdenv.mkDerivation rec {
pname = "polymc";
symlinkJoin {
name = "polymc";
inherit version;
src = lib.cleanSource self;
paths = [ polymcInner ];
nativeBuildInputs = [ cmake extra-cmake-modules ninja jdk ghc_filesystem file wrapQtAppsHook ];
buildInputs = [ qtbase quazip zlib qtcharts ];
nativeBuildInputs = [ wrapQtAppsHook ];
buildInputs = [ qtbase ];
dontWrapQtApps = true;
postUnpack = ''
# Copy libnbtplusplus
rm -rf source/libraries/libnbtplusplus
mkdir source/libraries/libnbtplusplus
cp -a ${libnbtplusplus}/* source/libraries/libnbtplusplus
chmod a+r+w source/libraries/libnbtplusplus/*
# Copy tomlplusplus
rm -rf source/libraries/tomlplusplus
mkdir source/libraries/tomlplusplus
cp -a ${tomlplusplus}/* source/libraries/tomlplusplus
chmod a+r+w source/libraries/tomlplusplus/*
postBuild = ''
wrapQtAppsHook
'';
cmakeFlags = [
"-GNinja"
"-DLauncher_QT_VERSION_MAJOR=${lib.versions.major qtbase.version}"
] ++ lib.optionals enableLTO [ "-DENABLE_LTO=on" ]
++ lib.optionals (msaClientID != "") [ "-DLauncher_MSA_CLIENT_ID=${msaClientID}" ];
qtWrapperArgs =
let
runtimeLibs = (with xorg; [
libX11
libXext
libXcursor
libXrandr
libXxf86vm
]) ++
# lwjgl
[
libpulseaudio
libGL
glfw
openal
stdenv.cc.cc.lib
udev # OSHI
];
in
[
"--prefix POLYMC_JAVA_PATHS : ${lib.makeSearchPath "bin/java" jdks}"
"--set LD_LIBRARY_PATH ${addOpenGLRunpath.driverLink}/lib:${lib.makeLibraryPath runtimeLibs}"
];
# we have to check if the system is NixOS before adding stdenv.cc.cc.lib (#923)
postInstall = ''
# xorg.xrandr needed for LWJGL [2.9.2, 3) https://github.com/LWJGL/lwjgl/issues/128
wrapQtApp $out/bin/polymc \
--run '[ -f /etc/NIXOS ] && export LD_LIBRARY_PATH="${stdenv.cc.cc.lib}/lib:$LD_LIBRARY_PATH"' \
--prefix LD_LIBRARY_PATH : ${gameLibraryPath} \
--prefix POLYMC_JAVA_PATHS : ${javaPaths} \
--prefix PATH : ${lib.makeBinPath [ xorg.xrandr ]}
'';
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 = platforms.unix;
license = licenses.gpl3Only;
maintainers = with maintainers; [ starcraft66 kloenk ];
};
inherit (polymcInner) meta;
}

68
nix/unwrapped.nix Normal file
View File

@ -0,0 +1,68 @@
{ stdenv
, lib
, cmake
, ninja
, jdk8
, ghc_filesystem
, zlib
, file
, qtbase
, quazip
, msaClientID ? ""
, extra-cmake-modules
, qtcharts
, qtwayland
# flake
, self
, version
, libnbtplusplus
, tomlplusplus
, enableLTO ? false
}:
stdenv.mkDerivation {
pname = "polymc-unwrapped";
inherit version;
src = lib.cleanSource self;
nativeBuildInputs = [ cmake extra-cmake-modules ninja jdk8 ghc_filesystem file ];
buildInputs = [ qtbase quazip zlib qtcharts ] ++ lib.optional (lib.versionAtLeast qtbase.version "6") qtwayland;
postUnpack = ''
# Copy libnbtplusplus
rm -rf source/libraries/libnbtplusplus
mkdir source/libraries/libnbtplusplus
cp -a ${libnbtplusplus}/* source/libraries/libnbtplusplus
chmod a+r+w source/libraries/libnbtplusplus/*
# Copy tomlplusplus
rm -rf source/libraries/tomlplusplus
mkdir source/libraries/tomlplusplus
cp -a ${tomlplusplus}/* source/libraries/tomlplusplus
chmod a+r+w source/libraries/tomlplusplus/*
'';
dontWrapQtApps = true;
cmakeFlags = [
"-GNinja"
"-DLauncher_QT_VERSION_MAJOR=${lib.versions.major qtbase.version}"
]
++ lib.optionals enableLTO [ "-DENABLE_LTO=on" ]
++ lib.optionals (msaClientID != "") [ "-DLauncher_MSA_CLIENT_ID=${msaClientID}" ];
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 = platforms.unix;
license = licenses.gpl3Only;
maintainers = with maintainers; [ starcraft66 kloenk ];
};
}