Merge pull request #653 from muscaln/nix

This commit is contained in:
Sefa Eyeoglu 2022-05-29 13:08:56 +02:00 committed by GitHub
commit 4a0b0d8735
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 30 additions and 52 deletions

View File

@ -1 +1 @@
(import packages/nix/flake-compat.nix).defaultNix
(import nix/flake-compat.nix).defaultNix

View File

@ -3,11 +3,11 @@
"flake-compat": {
"flake": false,
"locked": {
"lastModified": 1648199409,
"narHash": "sha256-JwPKdC2PoVBkG6E+eWw3j6BMR6sL3COpYWfif7RVb8Y=",
"lastModified": 1650374568,
"narHash": "sha256-Z+s0J8/r907g149rllvwhb4pKi8Wam5ij0st8PwAh+E=",
"owner": "edolstra",
"repo": "flake-compat",
"rev": "64a525ee38886ab9028e6f61790de0832aa3ef03",
"rev": "b4a34015c698c7793d592d66adbab377907a2be8",
"type": "github"
},
"original": {
@ -34,11 +34,11 @@
},
"nixpkgs": {
"locked": {
"lastModified": 1648219316,
"narHash": "sha256-Ctij+dOi0ZZIfX5eMhgwugfvB+WZSrvVNAyAuANOsnQ=",
"lastModified": 1653326962,
"narHash": "sha256-W8feCYqKTsMre4nAEpv5Kx1PVFC+hao/LwqtB2Wci/8=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "30d3d79b7d3607d56546dd2a6b49e156ba0ec634",
"rev": "41cc1d5d9584103be4108c1815c350e07c807036",
"type": "github"
},
"original": {
@ -48,28 +48,11 @@
"type": "github"
}
},
"quazip": {
"flake": false,
"locked": {
"lastModified": 1643049383,
"narHash": "sha256-LcJY6yd6GyeL7X5MP4L94diceM1TYespWByliBsjK98=",
"owner": "stachenov",
"repo": "quazip",
"rev": "09ec1d10c6d627f895109b21728dda000cbfa7d1",
"type": "github"
},
"original": {
"owner": "stachenov",
"repo": "quazip",
"type": "github"
}
},
"root": {
"inputs": {
"flake-compat": "flake-compat",
"libnbtplusplus": "libnbtplusplus",
"nixpkgs": "nixpkgs",
"quazip": "quazip"
"nixpkgs": "nixpkgs"
}
}
},

View File

@ -5,10 +5,9 @@
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
flake-compat = { url = "github:edolstra/flake-compat"; flake = false; };
libnbtplusplus = { url = "github:multimc/libnbtplusplus"; flake = false; };
quazip = { url = "github:stachenov/quazip"; flake = false; };
};
outputs = { self, nixpkgs, libnbtplusplus, quazip, ... }:
outputs = { self, nixpkgs, libnbtplusplus, ... }:
let
# Generate a user-friendly version number.
version = builtins.substring 0 8 self.lastModifiedDate;
@ -23,7 +22,11 @@
pkgs = forAllSystems (system: nixpkgs.legacyPackages.${system});
in
{
packages = forAllSystems (system: { polymc = pkgs.${system}.libsForQt5.callPackage ./packages/nix/polymc { inherit version self quazip libnbtplusplus; }; });
packages = forAllSystems (system: {
polymc = pkgs.${system}.libsForQt5.callPackage ./nix { inherit version self libnbtplusplus; };
polymc-qt6 = pkgs.${system}.qt6Packages.callPackage ./nix { inherit version self libnbtplusplus; };
});
defaultPackage = forAllSystems (system: self.packages.${system}.polymc);
apps = forAllSystems (system: { polymc = { type = "app"; program = "${self.defaultPackage.${system}}/bin/polymc"; }; });

View File

@ -1,5 +1,5 @@
{ lib
, mkDerivation
{ stdenv
, lib
, fetchFromGitHub
, cmake
, ninja
@ -7,7 +7,7 @@
, jdk
, zlib
, file
, makeWrapper
, wrapQtAppsHook
, xorg
, libpulseaudio
, qtbase
@ -18,7 +18,6 @@
, self
, version
, libnbtplusplus
, quazip
}:
let
@ -37,41 +36,34 @@ let
gameLibraryPath = libpath + ":/run/opengl-driver/lib";
in
mkDerivation rec {
stdenv.mkDerivation rec {
pname = "polymc";
inherit version;
src = lib.cleanSource self;
nativeBuildInputs = [ cmake ninja file makeWrapper ];
buildInputs = [ qtbase jdk zlib ];
nativeBuildInputs = [ cmake ninja jdk file wrapQtAppsHook ];
buildInputs = [ qtbase quazip zlib ];
dontWrapQtApps = true;
postPatch = lib.optionalString (msaClientID != "") ''
# add client ID
substituteInPlace CMakeLists.txt \
--replace '17b47edd-c884-4997-926d-9e7f9a6b4647' '${msaClientID}'
'';
postUnpack = ''
# Copy submodules inputs
rm -rf source/libraries/{libnbtplusplus,quazip}
mkdir source/libraries/{libnbtplusplus,quazip}
# Copy libnbtplusplus
rm -rf source/libraries/libnbtplusplus
mkdir source/libraries/libnbtplusplus
cp -a ${libnbtplusplus}/* source/libraries/libnbtplusplus
cp -a ${quazip}/* source/libraries/quazip
chmod a+r+w source/libraries/{libnbtplusplus,quazip}/*
chmod a+r+w source/libraries/libnbtplusplus/*
'';
cmakeFlags = [
"-GNinja"
"-DLauncher_PORTABLE=OFF"
];
"-DENABLE_LTO=on"
"-DLauncher_QT_VERSION_MAJOR=${lib.versions.major qtbase.version}"
] ++ lib.optionals (msaClientID != "") [ "-DLauncher_MSA_CLIENT_ID=${msaClientID}" ];
postInstall = ''
# xorg.xrandr needed for LWJGL [2.9.2, 3) https://github.com/LWJGL/lwjgl/issues/128
wrapProgram $out/bin/polymc \
"''${qtWrapperArgs[@]}" \
wrapQtApp $out/bin/polymc \
--set GAME_LIBRARY_PATH ${gameLibraryPath} \
--prefix POLYMC_JAVA_PATHS : ${jdk}/lib/openjdk/bin/java:${jdk8}/lib/openjdk/bin/java \
--prefix PATH : ${lib.makeBinPath [ xorg.xrandr ]}

View File

@ -1,9 +1,9 @@
let
lock = builtins.fromJSON (builtins.readFile ../../flake.lock);
lock = builtins.fromJSON (builtins.readFile ../flake.lock);
inherit (lock.nodes.flake-compat.locked) rev narHash;
flake-compat = fetchTarball {
url = "https://github.com/edolstra/flake-compat/archive/${rev}.tar.gz";
sha256 = narHash;
};
in
import flake-compat { src = ../..; }
import flake-compat { src = ../.; }