From e1f1779162cd32c82a210a540ed89464eb65680d Mon Sep 17 00:00:00 2001 From: Evan Goode Date: Sat, 26 Oct 2024 15:25:27 -0400 Subject: [PATCH] Fix build? --- .github/workflows/build.yml | 2 +- flake.nix | 204 +++++++++--------- launcher/java/JavaUtils.cpp | 3 - launcher/minecraft/auth/AuthFlow.h | 1 + launcher/minecraft/auth/MinecraftAccount.h | 1 + launcher/minecraft/auth/steps/MSAStep.cpp | 8 + launcher/minecraft/auth/steps/YggdrasilStep.h | 1 + nix/README.md | 8 +- nix/dev.nix | 63 +++--- nix/distribution.nix | 56 ++--- nix/pkg/default.nix | 134 ++++++------ nix/pkg/wrapper.nix | 122 ++++++----- nix/unwrapped.nix | 147 +++++++------ nix/wrapper.nix | 126 +++++------ program_info/shell.nix | 11 +- tests/Manifest_test.cpp | 6 +- 16 files changed, 468 insertions(+), 425 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4bdd138bb..cce6e2959 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -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 diff --git a/flake.nix b/flake.nix index d7d1c7449..e256d7ef8 100644 --- a/flake.nix +++ b/flake.nix @@ -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=" ]; }; @@ -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 = { @@ -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; + }; + } + ); + }; } diff --git a/launcher/java/JavaUtils.cpp b/launcher/java/JavaUtils.cpp index 5026df7d5..beb54b003 100644 --- a/launcher/java/JavaUtils.cpp +++ b/launcher/java/JavaUtils.cpp @@ -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", ""); diff --git a/launcher/minecraft/auth/AuthFlow.h b/launcher/minecraft/auth/AuthFlow.h index e5db51d4c..a5aea9fa1 100644 --- a/launcher/minecraft/auth/AuthFlow.h +++ b/launcher/minecraft/auth/AuthFlow.h @@ -6,6 +6,7 @@ #include #include #include +#include #include "minecraft/auth/AccountData.h" #include "minecraft/auth/AuthStep.h" diff --git a/launcher/minecraft/auth/MinecraftAccount.h b/launcher/minecraft/auth/MinecraftAccount.h index d1b574997..5b479f7a1 100644 --- a/launcher/minecraft/auth/MinecraftAccount.h +++ b/launcher/minecraft/auth/MinecraftAccount.h @@ -42,6 +42,7 @@ #include #include #include +#include #include "AccountData.h" #include "AuthSession.h" diff --git a/launcher/minecraft/auth/steps/MSAStep.cpp b/launcher/minecraft/auth/steps/MSAStep.cpp index 91c596b17..d5aa05152 100644 --- a/launcher/minecraft/auth/steps/MSAStep.cpp +++ b/launcher/minecraft/auth/steps/MSAStep.cpp @@ -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* parameters) { if (stage == QAbstractOAuth::Stage::RefreshingAccessToken) { (*parameters).insert("scope", scope); } }); +#endif oauth2.setClientIdentifier(m_clientId); oauth2.setNetworkAccessManager(APPLICATION->network().get()); diff --git a/launcher/minecraft/auth/steps/YggdrasilStep.h b/launcher/minecraft/auth/steps/YggdrasilStep.h index 0cc558d45..70f4f40f8 100644 --- a/launcher/minecraft/auth/steps/YggdrasilStep.h +++ b/launcher/minecraft/auth/steps/YggdrasilStep.h @@ -1,5 +1,6 @@ #pragma once #include +#include #include "minecraft/auth/AuthStep.h" #include "net/NetJob.h" diff --git a/nix/README.md b/nix/README.md index 032fa2b8e..f081d771a 100644 --- a/nix/README.md +++ b/nix/README.md @@ -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=" ]; }; } diff --git a/nix/dev.nix b/nix/dev.nix index 08bbeea3f..71745a1c4 100644 --- a/nix/dev.nix +++ b/nix/dev.nix @@ -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; - }; } diff --git a/nix/distribution.nix b/nix/distribution.nix index 8981fa6af..a37c354ea 100644 --- a/nix/distribution.nix +++ b/nix/distribution.nix @@ -2,36 +2,40 @@ inputs, self, ... -}: { - perSystem = { - lib, - pkgs, - ... - }: { - packages = let - ourPackages = lib.fix (final: self.overlays.default final pkgs); - in { - inherit - (ourPackages) - fjordlauncher-unwrapped - fjordlauncher - ; - default = ourPackages.fjordlauncher; +}: +{ + perSystem = + { + lib, + pkgs, + ... + }: + { + packages = + let + ourPackages = lib.fix (final: self.overlays.default final pkgs); + in + { + inherit (ourPackages) fjordlauncher-unwrapped fjordlauncher; + default = ourPackages.fjordlauncher; + }; }; - }; flake = { - overlays.default = final: prev: let - version = builtins.substring 0 8 self.lastModifiedDate or "dirty"; - in { - fjordlauncher-unwrapped = prev.callPackage ./pkg { - inherit (inputs) libnbtplusplus; - inherit version; - }; + overlays.default = + final: prev: + let + version = builtins.substring 0 8 self.lastModifiedDate or "dirty"; + in + { + fjordlauncher-unwrapped = prev.callPackage ./pkg { + inherit (inputs) libnbtplusplus; + inherit version; + }; - fjordlauncher = prev.qt6Packages.callPackage ./pkg/wrapper.nix { - inherit (final) fjordlauncher-unwrapped; + fjordlauncher = prev.qt6Packages.callPackage ./pkg/wrapper.nix { + inherit (final) fjordlauncher-unwrapped; + }; }; - }; }; } diff --git a/nix/pkg/default.nix b/nix/pkg/default.nix index 7f6aacdfa..ac4e26e43 100644 --- a/nix/pkg/default.nix +++ b/nix/pkg/default.nix @@ -21,13 +21,14 @@ assert lib.assertMsg ( gamemodeSupport -> stdenv.isLinux ) "gamemodeSupport is only available on Linux."; - stdenv.mkDerivation { - pname = "fjordlauncher-unwrapped"; - inherit version; +stdenv.mkDerivation { + pname = "fjordlauncher-unwrapped"; + inherit version; - src = lib.fileset.toSource { - root = ../../.; - fileset = lib.fileset.unions (map (fileName: ../../${fileName}) [ + src = lib.fileset.toSource { + root = ../../.; + fileset = lib.fileset.unions ( + map (fileName: ../../${fileName}) [ "buildconfig" "cmake" "launcher" @@ -36,70 +37,71 @@ assert lib.assertMsg ( "tests" "COPYING.md" "CMakeLists.txt" - ]); - }; + ] + ); + }; - postUnpack = '' - rm -rf source/libraries/libnbtplusplus - ln -s ${libnbtplusplus} source/libraries/libnbtplusplus - ''; + postUnpack = '' + rm -rf source/libraries/libnbtplusplus + ln -s ${libnbtplusplus} source/libraries/libnbtplusplus + ''; - nativeBuildInputs = [ - cmake - ninja - extra-cmake-modules - jdk17 - stripJavaArchivesHook - ]; + nativeBuildInputs = [ + cmake + ninja + extra-cmake-modules + jdk17 + stripJavaArchivesHook + ]; - buildInputs = - [ - cmark - ghc_filesystem - kdePackages.qtbase - kdePackages.qtnetworkauth - kdePackages.quazip - tomlplusplus - zlib - ] - ++ lib.optionals stdenv.isDarwin [darwin.apple_sdk.frameworks.Cocoa] - ++ lib.optional gamemodeSupport gamemode; + buildInputs = + [ + cmark + ghc_filesystem + kdePackages.qtbase + kdePackages.qtnetworkauth + kdePackages.quazip + tomlplusplus + zlib + ] + ++ lib.optionals stdenv.isDarwin [ darwin.apple_sdk.frameworks.Cocoa ] + ++ lib.optional gamemodeSupport gamemode; - hardeningEnable = lib.optionals stdenv.isLinux ["pie"]; + hardeningEnable = lib.optionals stdenv.isLinux [ "pie" ]; - cmakeFlags = - [ - (lib.cmakeFeature "Launcher_BUILD_PLATFORM" "nixpkgs") - ] - ++ lib.optionals (msaClientID != null) [ - (lib.cmakeFeature "Launcher_MSA_CLIENT_ID" (toString msaClientID)) - ] - ++ lib.optionals (lib.versionOlder kdePackages.qtbase.version "6") [ - (lib.cmakeFeature "Launcher_QT_VERSION_MAJOR" "5") - ] - ++ lib.optionals stdenv.isDarwin [ - # we wrap our binary manually - (lib.cmakeFeature "INSTALL_BUNDLE" "nodeps") - # disable built-in updater - (lib.cmakeFeature "MACOSX_SPARKLE_UPDATE_FEED_URL" "''") - (lib.cmakeFeature "CMAKE_INSTALL_PREFIX" "${placeholder "out"}/Applications/") - ]; + cmakeFlags = + [ + (lib.cmakeFeature "Launcher_BUILD_PLATFORM" "nixpkgs") + ] + ++ lib.optionals (msaClientID != null) [ + (lib.cmakeFeature "Launcher_MSA_CLIENT_ID" (toString msaClientID)) + ] + ++ lib.optionals (lib.versionOlder kdePackages.qtbase.version "6") [ + (lib.cmakeFeature "Launcher_QT_VERSION_MAJOR" "5") + ] + ++ lib.optionals stdenv.isDarwin [ + # we wrap our binary manually + (lib.cmakeFeature "INSTALL_BUNDLE" "nodeps") + # disable built-in updater + (lib.cmakeFeature "MACOSX_SPARKLE_UPDATE_FEED_URL" "''") + (lib.cmakeFeature "CMAKE_INSTALL_PREFIX" "${placeholder "out"}/Applications/") + ]; - dontWrapQtApps = true; + dontWrapQtApps = true; - meta = { - description = "Prism Launcher fork with support for alternative auth servers"; - 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. - ''; - homepage = "https://fjordlauncher.org/"; - license = lib.licenses.gpl3Only; - maintainers = with lib.maintainers; [ - evan-goode - ]; - mainProgram = "fjordlauncher"; - platforms = lib.platforms.linux ++ lib.platforms.darwin; - }; - } + meta = { + description = "Prism Launcher fork with support for alternative auth servers"; + 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. + ''; + homepage = "https://fjordlauncher.org/"; + license = lib.licenses.gpl3Only; + maintainers = with lib.maintainers; [ + evan-goode + ]; + mainProgram = "fjordlauncher"; + platforms = lib.platforms.linux ++ lib.platforms.darwin; + }; +} diff --git a/nix/pkg/wrapper.nix b/nix/pkg/wrapper.nix index 10fcc68b7..08ff99ccf 100644 --- a/nix/pkg/wrapper.nix +++ b/nix/pkg/wrapper.nix @@ -22,8 +22,8 @@ udev, vulkan-loader, xorg, - additionalLibs ? [], - additionalPrograms ? [], + additionalLibs ? [ ], + additionalPrograms ? [ ], controllerSupport ? stdenv.isLinux, gamemodeSupport ? stdenv.isLinux, jdks ? [ @@ -50,47 +50,48 @@ assert lib.assertMsg ( ) "textToSpeechSupport only has an effect on Linux."; assert lib.assertMsg ( withWaylandGLFW -> stdenv.isLinux -) "withWaylandGLFW is only available on Linux."; let - fjordlauncher' = fjordlauncher-unwrapped.override {inherit msaClientID gamemodeSupport;}; +) "withWaylandGLFW is only available on Linux."; +let + fjordlauncher' = fjordlauncher-unwrapped.override { inherit msaClientID gamemodeSupport; }; in - symlinkJoin { - name = "fjordlauncher-${fjordlauncher'.version}"; +symlinkJoin { + name = "fjordlauncher-${fjordlauncher'.version}"; - paths = [fjordlauncher']; + paths = [ fjordlauncher' ]; - nativeBuildInputs = - [kdePackages.wrapQtAppsHook] - # purposefully using a shell wrapper here for variable expansion - # see https://github.com/NixOS/nixpkgs/issues/172583 - ++ lib.optional withWaylandGLFW makeWrapper; + nativeBuildInputs = + [ kdePackages.wrapQtAppsHook ] + # purposefully using a shell wrapper here for variable expansion + # see https://github.com/NixOS/nixpkgs/issues/172583 + ++ lib.optional withWaylandGLFW makeWrapper; - buildInputs = - [ - kdePackages.qtbase - kdePackages.qtsvg - ] - ++ lib.optional ( - lib.versionAtLeast kdePackages.qtbase.version "6" && stdenv.isLinux - ) - kdePackages.qtwayland; + buildInputs = + [ + kdePackages.qtbase + kdePackages.qtsvg + ] + ++ lib.optional ( + lib.versionAtLeast kdePackages.qtbase.version "6" && stdenv.isLinux + ) kdePackages.qtwayland; - env = { - waylandPreExec = lib.optionalString withWaylandGLFW '' - if [ -n "$WAYLAND_DISPLAY" ]; then - export LD_LIBRARY_PATH=${lib.getLib glfw-wayland-minecraft}/lib:"$LD_LIBRARY_PATH" - fi - ''; - }; + env = { + waylandPreExec = lib.optionalString withWaylandGLFW '' + if [ -n "$WAYLAND_DISPLAY" ]; then + export LD_LIBRARY_PATH=${lib.getLib glfw-wayland-minecraft}/lib:"$LD_LIBRARY_PATH" + fi + ''; + }; - postBuild = - lib.optionalString withWaylandGLFW '' - qtWrapperArgs+=(--run "$waylandPreExec") - '' - + '' - wrapQtAppsHook - ''; + postBuild = + lib.optionalString withWaylandGLFW '' + qtWrapperArgs+=(--run "$waylandPreExec") + '' + + '' + wrapQtAppsHook + ''; - qtWrapperArgs = let + qtWrapperArgs = + let runtimeLibs = [ # lwjgl @@ -115,31 +116,28 @@ in ++ lib.optional controllerSupport libusb1 ++ additionalLibs; - runtimePrograms = - [ - glxinfo - pciutils # need lspci - xorg.xrandr # needed for LWJGL [2.9.2, 3) https://github.com/LWJGL/lwjgl/issues/128 - ] - ++ additionalPrograms; + runtimePrograms = [ + glxinfo + pciutils # need lspci + xorg.xrandr # needed for LWJGL [2.9.2, 3) https://github.com/LWJGL/lwjgl/issues/128 + ] ++ additionalPrograms; in - ["--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}" - ]; + [ "--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) - description - longDescription - homepage - changelog - license - maintainers - mainProgram - platforms - ; - }; - } + meta = { + inherit (fjordlauncher'.meta) + description + longDescription + homepage + changelog + license + maintainers + mainProgram + platforms + ; + }; +} diff --git a/nix/unwrapped.nix b/nix/unwrapped.nix index 39dae028e..b1d1dd7c1 100644 --- a/nix/unwrapped.nix +++ b/nix/unwrapped.nix @@ -23,86 +23,85 @@ assert lib.assertMsg ( gamemodeSupport -> stdenv.isLinux ) "gamemodeSupport is only available on Linux."; - stdenv.mkDerivation { - pname = "fjordlauncher-unwrapped"; - inherit version; +stdenv.mkDerivation { + pname = "fjordlauncher-unwrapped"; + inherit version; - src = nix-filter.lib { - root = self; - include = [ - "buildconfig" - "cmake" - "launcher" - "libraries" - "program_info" - "tests" - ../COPYING.md - ../CMakeLists.txt - ]; - }; + src = nix-filter.lib { + root = self; + include = [ + "buildconfig" + "cmake" + "launcher" + "libraries" + "program_info" + "tests" + ../COPYING.md + ../CMakeLists.txt + ]; + }; - postUnpack = '' - rm -rf source/libraries/libnbtplusplus - ln -s ${libnbtplusplus} source/libraries/libnbtplusplus - ''; + postUnpack = '' + rm -rf source/libraries/libnbtplusplus + ln -s ${libnbtplusplus} source/libraries/libnbtplusplus + ''; - nativeBuildInputs = [ - cmake - ninja - extra-cmake-modules - jdk17 - stripJavaArchivesHook - ]; + nativeBuildInputs = [ + cmake + ninja + extra-cmake-modules + jdk17 + stripJavaArchivesHook + ]; - buildInputs = - [ - cmark - ghc_filesystem - kdePackages.qtbase - kdePackages.qtnetworkauth - kdePackages.quazip - tomlplusplus - zlib - ] - ++ lib.optionals stdenv.isDarwin [darwin.apple_sdk.frameworks.Cocoa] - ++ lib.optional gamemodeSupport gamemode; + buildInputs = + [ + cmark + ghc_filesystem + kdePackages.qtbase + kdePackages.qtnetworkauth + kdePackages.quazip + tomlplusplus + zlib + ] + ++ lib.optionals stdenv.isDarwin [ darwin.apple_sdk.frameworks.Cocoa ] + ++ lib.optional gamemodeSupport gamemode; - hardeningEnable = lib.optionals stdenv.isLinux ["pie"]; + hardeningEnable = lib.optionals stdenv.isLinux [ "pie" ]; - cmakeFlags = - [(lib.cmakeFeature "Launcher_BUILD_PLATFORM" "nixpkgs")] - ++ lib.optionals (msaClientID != null) [ - (lib.cmakeFeature "Launcher_MSA_CLIENT_ID" (toString msaClientID)) - ] - ++ lib.optionals (lib.versionOlder kdePackages.qtbase.version "6") [ - (lib.cmakeFeature "Launcher_QT_VERSION_MAJOR" "5") - ] - ++ lib.optionals stdenv.isDarwin [ - # we wrap our binary manually - (lib.cmakeFeature "INSTALL_BUNDLE" "nodeps") - # disable built-in updater - (lib.cmakeFeature "MACOSX_SPARKLE_UPDATE_FEED_URL" "''") - (lib.cmakeFeature "CMAKE_INSTALL_PREFIX" "${placeholder "out"}/Applications/") - ]; + cmakeFlags = + [ (lib.cmakeFeature "Launcher_BUILD_PLATFORM" "nixpkgs") ] + ++ lib.optionals (msaClientID != null) [ + (lib.cmakeFeature "Launcher_MSA_CLIENT_ID" (toString msaClientID)) + ] + ++ lib.optionals (lib.versionOlder kdePackages.qtbase.version "6") [ + (lib.cmakeFeature "Launcher_QT_VERSION_MAJOR" "5") + ] + ++ lib.optionals stdenv.isDarwin [ + # we wrap our binary manually + (lib.cmakeFeature "INSTALL_BUNDLE" "nodeps") + # disable built-in updater + (lib.cmakeFeature "MACOSX_SPARKLE_UPDATE_FEED_URL" "''") + (lib.cmakeFeature "CMAKE_INSTALL_PREFIX" "${placeholder "out"}/Applications/") + ]; - doCheck = true; + doCheck = true; - dontWrapQtApps = true; + dontWrapQtApps = true; - meta = { - description = "Prism Launcher fork with support for alternative auth servers"; - 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. - ''; - homepage = "https://github.com/unmojang/FjordLauncher"; - license = lib.licenses.gpl3Only; - maintainers = with lib.maintainers; [ - Scrumplex - getchoo - ]; - mainProgram = "fjordlauncher"; - platforms = lib.platforms.linux ++ lib.platforms.darwin; - }; - } + meta = { + description = "Prism Launcher fork with support for alternative auth servers"; + 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. + ''; + homepage = "https://github.com/unmojang/FjordLauncher"; + license = lib.licenses.gpl3Only; + maintainers = with lib.maintainers; [ + evan-goode + ]; + mainProgram = "fjordlauncher"; + platforms = lib.platforms.linux ++ lib.platforms.darwin; + }; +} diff --git a/nix/wrapper.nix b/nix/wrapper.nix index 10fcc68b7..3cb77aa03 100644 --- a/nix/wrapper.nix +++ b/nix/wrapper.nix @@ -22,8 +22,8 @@ udev, vulkan-loader, xorg, - additionalLibs ? [], - additionalPrograms ? [], + additionalLibs ? [ ], + additionalPrograms ? [ ], controllerSupport ? stdenv.isLinux, gamemodeSupport ? stdenv.isLinux, jdks ? [ @@ -50,47 +50,50 @@ assert lib.assertMsg ( ) "textToSpeechSupport only has an effect on Linux."; assert lib.assertMsg ( withWaylandGLFW -> stdenv.isLinux -) "withWaylandGLFW is only available on Linux."; let - fjordlauncher' = fjordlauncher-unwrapped.override {inherit msaClientID gamemodeSupport;}; +) "withWaylandGLFW is only available on Linux."; +let + fjordlauncher' = fjordlauncher-unwrapped.override { inherit msaClientID gamemodeSupport; }; in - symlinkJoin { - name = "fjordlauncher-${fjordlauncher'.version}"; +symlinkJoin { + name = "fjordlauncher-${fjordlauncher'.version}"; - paths = [fjordlauncher']; + paths = [ fjordlauncher' ]; - nativeBuildInputs = - [kdePackages.wrapQtAppsHook] - # purposefully using a shell wrapper here for variable expansion - # see https://github.com/NixOS/nixpkgs/issues/172583 - ++ lib.optional withWaylandGLFW makeWrapper; + nativeBuildInputs = + [ + kdePackages.wrapQtAppsHook + ] + # purposefully using a shell wrapper here for variable expansion + # see https://github.com/NixOS/nixpkgs/issues/172583 + ++ lib.optional withWaylandGLFW makeWrapper; - buildInputs = - [ - kdePackages.qtbase - kdePackages.qtsvg - ] - ++ lib.optional ( - lib.versionAtLeast kdePackages.qtbase.version "6" && stdenv.isLinux - ) - kdePackages.qtwayland; + buildInputs = + [ + kdePackages.qtbase + kdePackages.qtsvg + ] + ++ lib.optional ( + lib.versionAtLeast kdePackages.qtbase.version "6" && stdenv.isLinux + ) kdePackages.qtwayland; - env = { - waylandPreExec = lib.optionalString withWaylandGLFW '' - if [ -n "$WAYLAND_DISPLAY" ]; then - export LD_LIBRARY_PATH=${lib.getLib glfw-wayland-minecraft}/lib:"$LD_LIBRARY_PATH" - fi - ''; - }; + env = { + waylandPreExec = lib.optionalString withWaylandGLFW '' + if [ -n "$WAYLAND_DISPLAY" ]; then + export LD_LIBRARY_PATH=${lib.getLib glfw-wayland-minecraft}/lib:"$LD_LIBRARY_PATH" + fi + ''; + }; - postBuild = - lib.optionalString withWaylandGLFW '' - qtWrapperArgs+=(--run "$waylandPreExec") - '' - + '' - wrapQtAppsHook - ''; + postBuild = + lib.optionalString withWaylandGLFW '' + qtWrapperArgs+=(--run "$waylandPreExec") + '' + + '' + wrapQtAppsHook + ''; - qtWrapperArgs = let + qtWrapperArgs = + let runtimeLibs = [ # lwjgl @@ -115,31 +118,30 @@ in ++ lib.optional controllerSupport libusb1 ++ additionalLibs; - runtimePrograms = - [ - glxinfo - pciutils # need lspci - xorg.xrandr # needed for LWJGL [2.9.2, 3) https://github.com/LWJGL/lwjgl/issues/128 - ] - ++ additionalPrograms; + runtimePrograms = [ + glxinfo + pciutils # need lspci + xorg.xrandr # needed for LWJGL [2.9.2, 3) https://github.com/LWJGL/lwjgl/issues/128 + ] ++ additionalPrograms; in - ["--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}" - ]; + [ + "--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) - description - longDescription - homepage - changelog - license - maintainers - mainProgram - platforms - ; - }; - } + meta = { + inherit (fjordlauncher'.meta) + description + longDescription + homepage + changelog + license + maintainers + mainProgram + platforms + ; + }; +} diff --git a/program_info/shell.nix b/program_info/shell.nix index cf728874b..631832d96 100644 --- a/program_info/shell.nix +++ b/program_info/shell.nix @@ -1,4 +1,11 @@ -{pkgs ? import {}}: +{ + pkgs ? import { }, +}: pkgs.mkShell { - nativeBuildInputs = with pkgs; [inkscape icoutils imagemagick nodePackages_latest.svgo]; + nativeBuildInputs = with pkgs; [ + inkscape + icoutils + imagemagick + nodePackages_latest.svgo + ]; } diff --git a/tests/Manifest_test.cpp b/tests/Manifest_test.cpp index 6d2882d83..e0ce02405 100644 --- a/tests/Manifest_test.cpp +++ b/tests/Manifest_test.cpp @@ -1,7 +1,7 @@ #include #include -#include +#include #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;