Fix build?

This commit is contained in:
Evan Goode 2024-10-26 15:25:27 -04:00
parent 7f52d57454
commit c15afbda4a
16 changed files with 469 additions and 426 deletions

View File

@ -681,7 +681,7 @@ jobs:
- name: Setup Cachix - name: Setup Cachix
uses: cachix/cachix-action@v15 uses: cachix/cachix-action@v15
with: with:
name: fjordlauncher name: unmojang
authToken: ${{ secrets.CACHIX_AUTH_TOKEN }} authToken: ${{ secrets.CACHIX_AUTH_TOKEN }}
- name: Run flake checks - name: Run flake checks

View File

@ -1,10 +1,10 @@
{ {
description = "A custom launcher for Minecraft that allows you to easily manage multiple installations of Minecraft at once (Fork of MultiMC)"; description = "Prism Launcher fork with support for alternative auth servers";
nixConfig = { nixConfig = {
extra-substituters = ["https://prismlauncher.cachix.org"]; extra-substituters = [ "https://unmojang.cachix.org" ];
extra-trusted-public-keys = [ extra-trusted-public-keys = [
"prismlauncher.cachix.org-1:9/n/FGyABA2jLUVfY+DEp4hKds/rwO+SCOtbOkDzd+c=" "unmojang.cachix.org-1:OfHnbBNduZ6Smx9oNbLFbYyvOWSoxb2uPcnXPj4EDQY="
]; ];
}; };
@ -39,13 +39,15 @@
}; };
}; };
outputs = { outputs =
{
self, self,
nixpkgs, nixpkgs,
libnbtplusplus, libnbtplusplus,
nix-filter, nix-filter,
... ...
}: let }:
let
inherit (nixpkgs) lib; inherit (nixpkgs) lib;
# While we only officially support aarch and x86_64 on Linux and MacOS, # While we only officially support aarch and x86_64 on Linux and MacOS,
@ -55,18 +57,22 @@
forAllSystems = lib.genAttrs systems; forAllSystems = lib.genAttrs systems;
nixpkgsFor = forAllSystems (system: nixpkgs.legacyPackages.${system}); nixpkgsFor = forAllSystems (system: nixpkgs.legacyPackages.${system});
in { in
{
checks = forAllSystems ( checks = forAllSystems (
system: let system:
let
checks' = nixpkgsFor.${system}.callPackage ./nix/checks.nix { inherit self; }; checks' = nixpkgsFor.${system}.callPackage ./nix/checks.nix { inherit self; };
in in
lib.filterAttrs (_: lib.isDerivation) checks' lib.filterAttrs (_: lib.isDerivation) checks'
); );
devShells = forAllSystems ( devShells = forAllSystems (
system: let system:
let
pkgs = nixpkgsFor.${system}; pkgs = nixpkgsFor.${system};
in { in
{
default = pkgs.mkShell { default = pkgs.mkShell {
inputsFrom = [ self.packages.${system}.fjordlauncher-unwrapped ]; inputsFrom = [ self.packages.${system}.fjordlauncher-unwrapped ];
buildInputs = with pkgs; [ buildInputs = with pkgs; [
@ -79,9 +85,12 @@
formatter = forAllSystems (system: nixpkgsFor.${system}.nixfmt-rfc-style); formatter = forAllSystems (system: nixpkgsFor.${system}.nixfmt-rfc-style);
overlays.default = final: prev: let overlays.default =
final: prev:
let
version = builtins.substring 0 8 self.lastModifiedDate or "dirty"; version = builtins.substring 0 8 self.lastModifiedDate or "dirty";
in { in
{
fjordlauncher-unwrapped = prev.callPackage ./nix/unwrapped.nix { fjordlauncher-unwrapped = prev.callPackage ./nix/unwrapped.nix {
inherit inherit
libnbtplusplus libnbtplusplus
@ -95,7 +104,8 @@
}; };
packages = forAllSystems ( packages = forAllSystems (
system: let system:
let
pkgs = nixpkgsFor.${system}; pkgs = nixpkgsFor.${system};
# Build a scope from our overlay # Build a scope from our overlay
@ -113,10 +123,12 @@
# We put these under legacyPackages as they are meant for CI, not end user consumption # We put these under legacyPackages as they are meant for CI, not end user consumption
legacyPackages = forAllSystems ( legacyPackages = forAllSystems (
system: let system:
let
fjordPackages = self.packages.${system}; fjordPackages = self.packages.${system};
legacyPackages = self.legacyPackages.${system}; legacyPackages = self.legacyPackages.${system};
in { in
{
fjordlauncher-debug = fjordPackages.fjordlauncher.override { fjordlauncher-debug = fjordPackages.fjordlauncher.override {
fjordlauncher-unwrapped = legacyPackages.fjordlauncher-unwrapped-debug; fjordlauncher-unwrapped = legacyPackages.fjordlauncher-unwrapped-debug;
}; };

View File

@ -500,9 +500,6 @@ QStringList getMinecraftJavaBundle()
auto appDataPath = QProcessEnvironment::systemEnvironment().value("APPDATA", ""); auto appDataPath = QProcessEnvironment::systemEnvironment().value("APPDATA", "");
processpaths << FS::PathCombine(QFileInfo(appDataPath).absoluteFilePath(), ".minecraft", "runtime"); processpaths << FS::PathCombine(QFileInfo(appDataPath).absoluteFilePath(), ".minecraft", "runtime");
auto appDataPath = QProcessEnvironment::systemEnvironment().value("APPDATA", "");
processpaths << FS::PathCombine(QFileInfo(appDataPath).absoluteFilePath(), ".minecraft", "runtime");
// add the microsoft store version of the launcher to the search. the current path is: // add the microsoft store version of the launcher to the search. the current path is:
// C:\Users\USERNAME\AppData\Local\Packages\Microsoft.4297127D64EC6_8wekyb3d8bbwe\LocalCache\Local\runtime // C:\Users\USERNAME\AppData\Local\Packages\Microsoft.4297127D64EC6_8wekyb3d8bbwe\LocalCache\Local\runtime
auto localAppDataPath = QProcessEnvironment::systemEnvironment().value("LOCALAPPDATA", ""); auto localAppDataPath = QProcessEnvironment::systemEnvironment().value("LOCALAPPDATA", "");

View File

@ -6,6 +6,7 @@
#include <QObject> #include <QObject>
#include <QSet> #include <QSet>
#include <QVector> #include <QVector>
#include <optional>
#include "minecraft/auth/AccountData.h" #include "minecraft/auth/AccountData.h"
#include "minecraft/auth/AuthStep.h" #include "minecraft/auth/AuthStep.h"

View File

@ -42,6 +42,7 @@
#include <QPair> #include <QPair>
#include <QPixmap> #include <QPixmap>
#include <QString> #include <QString>
#include <optional>
#include "AccountData.h" #include "AccountData.h"
#include "AuthSession.h" #include "AuthSession.h"

View File

@ -109,11 +109,19 @@ MSAStep::MSAStep(AccountData* data, bool silent) : AuthStep(data), m_silent(sile
const auto& scope = "service::user.auth.xboxlive.com::MBI_SSL"; const auto& scope = "service::user.auth.xboxlive.com::MBI_SSL";
oauth2.setScope(scope); oauth2.setScope(scope);
// QOAuth2AuthorizationCodeFlow doesn't pass a "scope" when refreshing access tokens, but Microsoft expects it. // QOAuth2AuthorizationCodeFlow doesn't pass a "scope" when refreshing access tokens, but Microsoft expects it.
oauth2.setModifyParametersFunction([](QAbstractOAuth::Stage stage, QMultiMap<QString, QVariant>* parameters) { #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
oauth2.setModifyParametersFunction([&](QAbstractOAuth::Stage stage, QVariantMap* parameters) {
if (stage == QAbstractOAuth::Stage::RefreshingAccessToken) {
(*parameters)["scope"] = scope;
}
});
#else
oauth2.setModifyParametersFunction([&](QAbstractOAuth::Stage stage, QMultiMap<QString, QVariant>* parameters) {
if (stage == QAbstractOAuth::Stage::RefreshingAccessToken) { if (stage == QAbstractOAuth::Stage::RefreshingAccessToken) {
(*parameters).insert("scope", scope); (*parameters).insert("scope", scope);
} }
}); });
#endif
oauth2.setClientIdentifier(m_clientId); oauth2.setClientIdentifier(m_clientId);
oauth2.setNetworkAccessManager(APPLICATION->network().get()); oauth2.setNetworkAccessManager(APPLICATION->network().get());

View File

@ -1,5 +1,6 @@
#pragma once #pragma once
#include <QObject> #include <QObject>
#include <optional>
#include "minecraft/auth/AuthStep.h" #include "minecraft/auth/AuthStep.h"
#include "net/NetJob.h" #include "net/NetJob.h"

View File

@ -17,10 +17,10 @@ Example (NixOS):
```nix ```nix
{ {
nix.settings = { nix.settings = {
trusted-substituters = [ "https://prismlauncher.cachix.org" ]; trusted-substituters = [ "https://unmojang.cachix.org" ];
trusted-public-keys = [ trusted-public-keys = [
"prismlauncher.cachix.org-1:9/n/FGyABA2jLUVfY+DEp4hKds/rwO+SCOtbOkDzd+c=" "unmojang.cachix.org-1:OfHnbBNduZ6Smx9oNbLFbYyvOWSoxb2uPcnXPj4EDQY="
]; ];
}; };
} }
@ -143,10 +143,10 @@ Example (NixOS):
```nix ```nix
{ {
nix.settings = { nix.settings = {
trusted-substituters = [ "https://prismlauncher.cachix.org" ]; trusted-substituters = [ "https://unmojang.cachix.org" ];
trusted-public-keys = [ trusted-public-keys = [
"prismlauncher.cachix.org-1:9/n/FGyABA2jLUVfY+DEp4hKds/rwO+SCOtbOkDzd+c=" "unmojang.cachix.org-1:OfHnbBNduZ6Smx9oNbLFbYyvOWSoxb2uPcnXPj4EDQY="
]; ];
}; };
} }

View File

@ -1,10 +1,12 @@
{ {
perSystem = { perSystem =
{
config, config,
lib, lib,
pkgs, pkgs,
... ...
}: { }:
{
pre-commit.settings = { pre-commit.settings = {
hooks = { hooks = {
markdownlint.enable = true; markdownlint.enable = true;
@ -15,7 +17,13 @@
clang-format = { clang-format = {
enable = true; enable = true;
types_or = ["c" "c++" "java" "json" "objective-c"]; types_or = [
"c"
"c++"
"java"
"json"
"objective-c"
];
}; };
}; };
@ -28,7 +36,10 @@
''; '';
inputsFrom = [ config.packages.fjordlauncher-unwrapped ]; inputsFrom = [ config.packages.fjordlauncher-unwrapped ];
buildInputs = with pkgs; [ccache ninja]; buildInputs = with pkgs; [
ccache
ninja
];
}; };
formatter = pkgs.alejandra; formatter = pkgs.alejandra;

View File

@ -2,28 +2,32 @@
inputs, inputs,
self, self,
... ...
}: { }:
perSystem = { {
perSystem =
{
lib, lib,
pkgs, pkgs,
... ...
}: { }:
packages = let {
packages =
let
ourPackages = lib.fix (final: self.overlays.default final pkgs); ourPackages = lib.fix (final: self.overlays.default final pkgs);
in { in
inherit {
(ourPackages) inherit (ourPackages) fjordlauncher-unwrapped fjordlauncher;
fjordlauncher-unwrapped
fjordlauncher
;
default = ourPackages.fjordlauncher; default = ourPackages.fjordlauncher;
}; };
}; };
flake = { flake = {
overlays.default = final: prev: let overlays.default =
final: prev:
let
version = builtins.substring 0 8 self.lastModifiedDate or "dirty"; version = builtins.substring 0 8 self.lastModifiedDate or "dirty";
in { in
{
fjordlauncher-unwrapped = prev.callPackage ./pkg { fjordlauncher-unwrapped = prev.callPackage ./pkg {
inherit (inputs) libnbtplusplus; inherit (inputs) libnbtplusplus;
inherit version; inherit version;

View File

@ -27,7 +27,8 @@ assert lib.assertMsg (
src = lib.fileset.toSource { src = lib.fileset.toSource {
root = ../../.; root = ../../.;
fileset = lib.fileset.unions (map (fileName: ../../${fileName}) [ fileset = lib.fileset.unions (
map (fileName: ../../${fileName}) [
"buildconfig" "buildconfig"
"cmake" "cmake"
"launcher" "launcher"
@ -36,7 +37,8 @@ assert lib.assertMsg (
"tests" "tests"
"COPYING.md" "COPYING.md"
"CMakeLists.txt" "CMakeLists.txt"
]); ]
);
}; };
postUnpack = '' postUnpack = ''

View File

@ -50,7 +50,8 @@ assert lib.assertMsg (
) "textToSpeechSupport only has an effect on Linux."; ) "textToSpeechSupport only has an effect on Linux.";
assert lib.assertMsg ( assert lib.assertMsg (
withWaylandGLFW -> stdenv.isLinux withWaylandGLFW -> stdenv.isLinux
) "withWaylandGLFW is only available on Linux."; let ) "withWaylandGLFW is only available on Linux.";
let
fjordlauncher' = fjordlauncher-unwrapped.override { inherit msaClientID gamemodeSupport; }; fjordlauncher' = fjordlauncher-unwrapped.override { inherit msaClientID gamemodeSupport; };
in in
symlinkJoin { symlinkJoin {
@ -71,8 +72,7 @@ in
] ]
++ lib.optional ( ++ lib.optional (
lib.versionAtLeast kdePackages.qtbase.version "6" && stdenv.isLinux lib.versionAtLeast kdePackages.qtbase.version "6" && stdenv.isLinux
) ) kdePackages.qtwayland;
kdePackages.qtwayland;
env = { env = {
waylandPreExec = lib.optionalString withWaylandGLFW '' waylandPreExec = lib.optionalString withWaylandGLFW ''
@ -90,7 +90,8 @@ in
wrapQtAppsHook wrapQtAppsHook
''; '';
qtWrapperArgs = let qtWrapperArgs =
let
runtimeLibs = runtimeLibs =
[ [
# lwjgl # lwjgl
@ -115,13 +116,11 @@ in
++ lib.optional controllerSupport libusb1 ++ lib.optional controllerSupport libusb1
++ additionalLibs; ++ additionalLibs;
runtimePrograms = runtimePrograms = [
[
glxinfo glxinfo
pciutils # need lspci pciutils # need lspci
xorg.xrandr # needed for LWJGL [2.9.2, 3) https://github.com/LWJGL/lwjgl/issues/128 xorg.xrandr # needed for LWJGL [2.9.2, 3) https://github.com/LWJGL/lwjgl/issues/128
] ] ++ additionalPrograms;
++ additionalPrograms;
in in
[ "--prefix FJORDLAUNCHER_JAVA_PATHS : ${lib.makeSearchPath "bin/java" jdks}" ] [ "--prefix FJORDLAUNCHER_JAVA_PATHS : ${lib.makeSearchPath "bin/java" jdks}" ]
++ lib.optionals stdenv.isLinux [ ++ lib.optionals stdenv.isLinux [
@ -130,8 +129,7 @@ in
]; ];
meta = { meta = {
inherit inherit (fjordlauncher'.meta)
(fjordlauncher'.meta)
description description
longDescription longDescription
homepage homepage

View File

@ -99,8 +99,7 @@ assert lib.assertMsg (
homepage = "https://github.com/unmojang/FjordLauncher"; homepage = "https://github.com/unmojang/FjordLauncher";
license = lib.licenses.gpl3Only; license = lib.licenses.gpl3Only;
maintainers = with lib.maintainers; [ maintainers = with lib.maintainers; [
Scrumplex evan-goode
getchoo
]; ];
mainProgram = "fjordlauncher"; mainProgram = "fjordlauncher";
platforms = lib.platforms.linux ++ lib.platforms.darwin; platforms = lib.platforms.linux ++ lib.platforms.darwin;

View File

@ -50,7 +50,8 @@ assert lib.assertMsg (
) "textToSpeechSupport only has an effect on Linux."; ) "textToSpeechSupport only has an effect on Linux.";
assert lib.assertMsg ( assert lib.assertMsg (
withWaylandGLFW -> stdenv.isLinux withWaylandGLFW -> stdenv.isLinux
) "withWaylandGLFW is only available on Linux."; let ) "withWaylandGLFW is only available on Linux.";
let
fjordlauncher' = fjordlauncher-unwrapped.override { inherit msaClientID gamemodeSupport; }; fjordlauncher' = fjordlauncher-unwrapped.override { inherit msaClientID gamemodeSupport; };
in in
symlinkJoin { symlinkJoin {
@ -59,7 +60,9 @@ in
paths = [ fjordlauncher' ]; paths = [ fjordlauncher' ];
nativeBuildInputs = nativeBuildInputs =
[kdePackages.wrapQtAppsHook] [
kdePackages.wrapQtAppsHook
]
# purposefully using a shell wrapper here for variable expansion # purposefully using a shell wrapper here for variable expansion
# see https://github.com/NixOS/nixpkgs/issues/172583 # see https://github.com/NixOS/nixpkgs/issues/172583
++ lib.optional withWaylandGLFW makeWrapper; ++ lib.optional withWaylandGLFW makeWrapper;
@ -71,8 +74,7 @@ in
] ]
++ lib.optional ( ++ lib.optional (
lib.versionAtLeast kdePackages.qtbase.version "6" && stdenv.isLinux lib.versionAtLeast kdePackages.qtbase.version "6" && stdenv.isLinux
) ) kdePackages.qtwayland;
kdePackages.qtwayland;
env = { env = {
waylandPreExec = lib.optionalString withWaylandGLFW '' waylandPreExec = lib.optionalString withWaylandGLFW ''
@ -90,7 +92,8 @@ in
wrapQtAppsHook wrapQtAppsHook
''; '';
qtWrapperArgs = let qtWrapperArgs =
let
runtimeLibs = runtimeLibs =
[ [
# lwjgl # lwjgl
@ -115,23 +118,22 @@ in
++ lib.optional controllerSupport libusb1 ++ lib.optional controllerSupport libusb1
++ additionalLibs; ++ additionalLibs;
runtimePrograms = runtimePrograms = [
[
glxinfo glxinfo
pciutils # need lspci pciutils # need lspci
xorg.xrandr # needed for LWJGL [2.9.2, 3) https://github.com/LWJGL/lwjgl/issues/128 xorg.xrandr # needed for LWJGL [2.9.2, 3) https://github.com/LWJGL/lwjgl/issues/128
] ] ++ additionalPrograms;
++ additionalPrograms;
in in
["--prefix FJORDLAUNCHER_JAVA_PATHS : ${lib.makeSearchPath "bin/java" jdks}"] [
"--prefix FJORDLAUNCHER_JAVA_PATHS : ${lib.makeSearchPath "bin/java" jdks}"
]
++ lib.optionals stdenv.isLinux [ ++ lib.optionals stdenv.isLinux [
"--set LD_LIBRARY_PATH ${addOpenGLRunpath.driverLink}/lib:${lib.makeLibraryPath runtimeLibs}" "--set LD_LIBRARY_PATH ${addOpenGLRunpath.driverLink}/lib:${lib.makeLibraryPath runtimeLibs}"
"--prefix PATH : ${lib.makeBinPath runtimePrograms}" "--prefix PATH : ${lib.makeBinPath runtimePrograms}"
]; ];
meta = { meta = {
inherit inherit (fjordlauncher'.meta)
(fjordlauncher'.meta)
description description
longDescription longDescription
homepage homepage

View File

@ -1,4 +1,11 @@
{pkgs ? import <nixos-unstable> {}}: {
pkgs ? import <nixos-unstable> { },
}:
pkgs.mkShell { pkgs.mkShell {
nativeBuildInputs = with pkgs; [inkscape icoutils imagemagick nodePackages_latest.svgo]; nativeBuildInputs = with pkgs; [
inkscape
icoutils
imagemagick
nodePackages_latest.svgo
];
} }

View File

@ -1,7 +1,7 @@
#include <QTest> #include <QTest>
#include <QTimer> #include <QTimer>
#include <iostream> #include <sstream>
#include "Manifest.h" #include "Manifest.h"
@ -93,7 +93,7 @@ A-Name-That-Is-Way-Too-Loooooooooooooooooooooooooooooooooooooooooooooooonooooooo
} }
QVERIFY(caught); QVERIFY(caught);
} }
void test_misingColon() void test_missingColon()
{ {
std::istringstream iss{ "Manifest-Version 1.0" }; std::istringstream iss{ "Manifest-Version 1.0" };
bool caught = false; bool caught = false;
@ -104,7 +104,7 @@ A-Name-That-Is-Way-Too-Loooooooooooooooooooooooooooooooooooooooooooooooonooooooo
} }
QVERIFY(caught); QVERIFY(caught);
} }
void test_misingSpace() void test_missingSpace()
{ {
std::istringstream iss{ "Manifest-Version:1.0" }; std::istringstream iss{ "Manifest-Version:1.0" };
bool caught = false; bool caught = false;