Skip to content

Commit

Permalink
Fix build?
Browse files Browse the repository at this point in the history
  • Loading branch information
evan-goode committed Oct 26, 2024
1 parent 7f52d57 commit 07240af
Show file tree
Hide file tree
Showing 15 changed files with 468 additions and 422 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
204 changes: 108 additions & 96 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -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="
];
};

Expand All @@ -19,18 +19,18 @@
nix-filter.url = "github:numtide/nix-filter";

/*
Inputs below this are optional and can be removed
```
{
inputs.fjordlauncher = {
url = "github:unmojang/FjordLauncher";
inputs = {
flake-compat.follows = "";
Inputs below this are optional and can be removed
```
{
inputs.fjordlauncher = {
url = "github:unmojang/FjordLauncher";
inputs = {
flake-compat.follows = "";
};
};
};
}
```
}
```
*/

flake-compat = {
Expand All @@ -39,93 +39,105 @@
};
};

outputs = {
self,
nixpkgs,
libnbtplusplus,
nix-filter,
...
}: let
inherit (nixpkgs) lib;

# While we only officially support aarch and x86_64 on Linux and MacOS,
# we expose a reasonable amount of other systems for users who want to
# build for most exotic platforms
systems = lib.systems.flakeExposed;

forAllSystems = lib.genAttrs systems;
nixpkgsFor = forAllSystems (system: nixpkgs.legacyPackages.${system});
in {
checks = forAllSystems (
system: let
checks' = nixpkgsFor.${system}.callPackage ./nix/checks.nix {inherit self;};
in
outputs =
{
self,
nixpkgs,
libnbtplusplus,
nix-filter,
...
}:
let
inherit (nixpkgs) lib;

# While we only officially support aarch and x86_64 on Linux and MacOS,
# we expose a reasonable amount of other systems for users who want to
# build for most exotic platforms
systems = lib.systems.flakeExposed;

forAllSystems = lib.genAttrs systems;
nixpkgsFor = forAllSystems (system: nixpkgs.legacyPackages.${system});
in
{
checks = forAllSystems (
system:
let
checks' = nixpkgsFor.${system}.callPackage ./nix/checks.nix { inherit self; };
in
lib.filterAttrs (_: lib.isDerivation) checks'
);

devShells = forAllSystems (
system: let
pkgs = nixpkgsFor.${system};
in {
default = pkgs.mkShell {
inputsFrom = [self.packages.${system}.fjordlauncher-unwrapped];
buildInputs = with pkgs; [
ccache
ninja
];
);

devShells = forAllSystems (
system:
let
pkgs = nixpkgsFor.${system};
in
{
default = pkgs.mkShell {
inputsFrom = [ self.packages.${system}.fjordlauncher-unwrapped ];
buildInputs = with pkgs; [
ccache
ninja
];
};
}
);

formatter = forAllSystems (system: nixpkgsFor.${system}.nixfmt-rfc-style);

overlays.default =
final: prev:
let
version = builtins.substring 0 8 self.lastModifiedDate or "dirty";
in
{
fjordlauncher-unwrapped = prev.callPackage ./nix/unwrapped.nix {
inherit
libnbtplusplus
nix-filter
self
version
;
};

fjordlauncher = final.callPackage ./nix/wrapper.nix { };
};
}
);

formatter = forAllSystems (system: nixpkgsFor.${system}.nixfmt-rfc-style);

overlays.default = final: prev: let
version = builtins.substring 0 8 self.lastModifiedDate or "dirty";
in {
fjordlauncher-unwrapped = prev.callPackage ./nix/unwrapped.nix {
inherit
libnbtplusplus
nix-filter
self
version
;
};

fjordlauncher = final.callPackage ./nix/wrapper.nix {};
};

packages = forAllSystems (
system: let
pkgs = nixpkgsFor.${system};
packages = forAllSystems (
system:
let
pkgs = nixpkgsFor.${system};

# Build a scope from our overlay
fjordPackages = lib.makeScope pkgs.newScope (final: self.overlays.default final pkgs);
# Build a scope from our overlay
fjordPackages = lib.makeScope pkgs.newScope (final: self.overlays.default final pkgs);

# Grab our packages from it and set the default
packages = {
inherit (fjordPackages) fjordlauncher-unwrapped fjordlauncher;
default = fjordPackages.fjordlauncher;
};
in
# Grab our packages from it and set the default
packages = {
inherit (fjordPackages) fjordlauncher-unwrapped fjordlauncher;
default = fjordPackages.fjordlauncher;
};
in
# Only output them if they're available on the current system
lib.filterAttrs (_: lib.meta.availableOn pkgs.stdenv.hostPlatform) packages
);

# We put these under legacyPackages as they are meant for CI, not end user consumption
legacyPackages = forAllSystems (
system: let
fjordPackages = self.packages.${system};
legacyPackages = self.legacyPackages.${system};
in {
fjordlauncher-debug = fjordPackages.fjordlauncher.override {
fjordlauncher-unwrapped = legacyPackages.fjordlauncher-unwrapped-debug;
};

fjordlauncher-unwrapped-debug = fjordPackages.fjordlauncher-unwrapped.overrideAttrs {
cmakeBuildType = "Debug";
dontStrip = true;
};
}
);
};
);

# We put these under legacyPackages as they are meant for CI, not end user consumption
legacyPackages = forAllSystems (
system:
let
fjordPackages = self.packages.${system};
legacyPackages = self.legacyPackages.${system};
in
{
fjordlauncher-debug = fjordPackages.fjordlauncher.override {
fjordlauncher-unwrapped = legacyPackages.fjordlauncher-unwrapped-debug;
};

fjordlauncher-unwrapped-debug = fjordPackages.fjordlauncher-unwrapped.overrideAttrs {
cmakeBuildType = "Debug";
dontStrip = true;
};
}
);
};
}
1 change: 1 addition & 0 deletions launcher/minecraft/auth/AuthFlow.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <QObject>
#include <QSet>
#include <QVector>
#include <optional>

#include "minecraft/auth/AccountData.h"
#include "minecraft/auth/AuthStep.h"
Expand Down
1 change: 1 addition & 0 deletions launcher/minecraft/auth/MinecraftAccount.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
#include <QPair>
#include <QPixmap>
#include <QString>
#include <optional>

#include "AccountData.h"
#include "AuthSession.h"
Expand Down
8 changes: 8 additions & 0 deletions launcher/minecraft/auth/steps/MSAStep.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
#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());

Expand Down
1 change: 1 addition & 0 deletions launcher/minecraft/auth/steps/YggdrasilStep.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#pragma once
#include <QObject>
#include <optional>

#include "minecraft/auth/AuthStep.h"
#include "net/NetJob.h"
Expand Down
8 changes: 4 additions & 4 deletions nix/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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="
];
};
}
Expand Down Expand Up @@ -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="
];
};
}
Expand Down
63 changes: 37 additions & 26 deletions nix/dev.nix
Original file line number Diff line number Diff line change
@@ -1,36 +1,47 @@
{
perSystem = {
config,
lib,
pkgs,
...
}: {
pre-commit.settings = {
hooks = {
markdownlint.enable = true;
perSystem =
{
config,
lib,
pkgs,
...
}:
{
pre-commit.settings = {
hooks = {
markdownlint.enable = true;

alejandra.enable = true;
deadnix.enable = true;
nil.enable = true;
alejandra.enable = true;
deadnix.enable = true;
nil.enable = true;

clang-format = {
enable = true;
types_or = ["c" "c++" "java" "json" "objective-c"];
clang-format = {
enable = true;
types_or = [
"c"
"c++"
"java"
"json"
"objective-c"
];
};
};

tools.clang-tools = lib.mkForce pkgs.clang-tools_18;
};

tools.clang-tools = lib.mkForce pkgs.clang-tools_18;
};
devShells.default = pkgs.mkShell {
shellHook = ''
${config.pre-commit.installationScript}
'';

devShells.default = pkgs.mkShell {
shellHook = ''
${config.pre-commit.installationScript}
'';
inputsFrom = [ config.packages.fjordlauncher-unwrapped ];
buildInputs = with pkgs; [
ccache
ninja
];
};

inputsFrom = [config.packages.fjordlauncher-unwrapped];
buildInputs = with pkgs; [ccache ninja];
formatter = pkgs.alejandra;
};

formatter = pkgs.alejandra;
};
}
Loading

0 comments on commit 07240af

Please sign in to comment.