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
uses: cachix/cachix-action@v15
with:
name: fjordlauncher
name: unmojang
authToken: ${{ secrets.CACHIX_AUTH_TOKEN }}
- 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 = {
extra-substituters = ["https://prismlauncher.cachix.org"];
extra-substituters = [ "https://unmojang.cachix.org" ];
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,
nixpkgs,
libnbtplusplus,
nix-filter,
...
}: let
}:
let
inherit (nixpkgs) lib;
# While we only officially support aarch and x86_64 on Linux and MacOS,
@ -55,18 +57,22 @@
forAllSystems = lib.genAttrs systems;
nixpkgsFor = forAllSystems (system: nixpkgs.legacyPackages.${system});
in {
in
{
checks = forAllSystems (
system: let
system:
let
checks' = nixpkgsFor.${system}.callPackage ./nix/checks.nix { inherit self; };
in
lib.filterAttrs (_: lib.isDerivation) checks'
);
devShells = forAllSystems (
system: let
system:
let
pkgs = nixpkgsFor.${system};
in {
in
{
default = pkgs.mkShell {
inputsFrom = [ self.packages.${system}.fjordlauncher-unwrapped ];
buildInputs = with pkgs; [
@ -79,9 +85,12 @@
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";
in {
in
{
fjordlauncher-unwrapped = prev.callPackage ./nix/unwrapped.nix {
inherit
libnbtplusplus
@ -95,7 +104,8 @@
};
packages = forAllSystems (
system: let
system:
let
pkgs = nixpkgsFor.${system};
# 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
legacyPackages = forAllSystems (
system: let
system:
let
fjordPackages = self.packages.${system};
legacyPackages = self.legacyPackages.${system};
in {
in
{
fjordlauncher-debug = fjordPackages.fjordlauncher.override {
fjordlauncher-unwrapped = legacyPackages.fjordlauncher-unwrapped-debug;
};

View File

@ -500,9 +500,6 @@ QStringList getMinecraftJavaBundle()
auto appDataPath = QProcessEnvironment::systemEnvironment().value("APPDATA", "");
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:
// C:\Users\USERNAME\AppData\Local\Packages\Microsoft.4297127D64EC6_8wekyb3d8bbwe\LocalCache\Local\runtime
auto localAppDataPath = QProcessEnvironment::systemEnvironment().value("LOCALAPPDATA", "");

View File

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

View File

@ -42,6 +42,7 @@
#include <QPair>
#include <QPixmap>
#include <QString>
#include <optional>
#include "AccountData.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";
oauth2.setScope(scope);
// 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) {
(*parameters).insert("scope", scope);
}
});
#endif
oauth2.setClientIdentifier(m_clientId);
oauth2.setNetworkAccessManager(APPLICATION->network().get());

View File

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

View File

@ -17,10 +17,10 @@ Example (NixOS):
```nix
{
nix.settings = {
trusted-substituters = [ "https://prismlauncher.cachix.org" ];
trusted-substituters = [ "https://unmojang.cachix.org" ];
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.settings = {
trusted-substituters = [ "https://prismlauncher.cachix.org" ];
trusted-substituters = [ "https://unmojang.cachix.org" ];
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,
lib,
pkgs,
...
}: {
}:
{
pre-commit.settings = {
hooks = {
markdownlint.enable = true;
@ -15,7 +17,13 @@
clang-format = {
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 ];
buildInputs = with pkgs; [ccache ninja];
buildInputs = with pkgs; [
ccache
ninja
];
};
formatter = pkgs.alejandra;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,4 +1,11 @@
{pkgs ? import <nixos-unstable> {}}:
{
pkgs ? import <nixos-unstable> { },
}:
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 <QTimer>
#include <iostream>
#include <sstream>
#include "Manifest.h"
@ -93,7 +93,7 @@ A-Name-That-Is-Way-Too-Loooooooooooooooooooooooooooooooooooooooooooooooonooooooo
}
QVERIFY(caught);
}
void test_misingColon()
void test_missingColon()
{
std::istringstream iss{ "Manifest-Version 1.0" };
bool caught = false;
@ -104,7 +104,7 @@ A-Name-That-Is-Way-Too-Loooooooooooooooooooooooooooooooooooooooooooooooonooooooo
}
QVERIFY(caught);
}
void test_misingSpace()
void test_missingSpace()
{
std::istringstream iss{ "Manifest-Version:1.0" };
bool caught = false;