From 7dff77ca356d93f0ef9de390276fce0a9c1a5ee6 Mon Sep 17 00:00:00 2001 From: seth Date: Tue, 20 Aug 2024 01:44:11 -0400 Subject: [PATCH 01/13] style(nix): alejandra -> nixfmt-rfc-style Signed-off-by: seth --- nix/dev.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nix/dev.nix b/nix/dev.nix index cf61449a7..22b4b43fb 100644 --- a/nix/dev.nix +++ b/nix/dev.nix @@ -9,9 +9,9 @@ hooks = { markdownlint.enable = true; - alejandra.enable = true; deadnix.enable = true; nil.enable = true; + nixfmt.enable = true; clang-format = { enable = true; @@ -31,6 +31,6 @@ buildInputs = with pkgs; [ccache ninja]; }; - formatter = pkgs.alejandra; + formatter = pkgs.nixfmt-rfc-style; }; } From 4c81d8c53d09196426568c4a31a4e752ed05397a Mon Sep 17 00:00:00 2001 From: seth Date: Tue, 20 Aug 2024 01:44:24 -0400 Subject: [PATCH 02/13] style(nix): format with nixfmt Signed-off-by: seth --- default.nix | 23 +++---- flake.nix | 13 ++-- nix/README.md | 72 ++++++++++++++-------- nix/dev.nix | 67 ++++++++++++--------- nix/distribution.nix | 54 ++++++++--------- nix/pkg/default.nix | 140 ++++++++++++++++++++++--------------------- nix/pkg/wrapper.nix | 126 +++++++++++++++++++------------------- 7 files changed, 259 insertions(+), 236 deletions(-) diff --git a/default.nix b/default.nix index c7d0c267d..6466507b7 100644 --- a/default.nix +++ b/default.nix @@ -1,14 +1,9 @@ -( - import - ( - let - lock = builtins.fromJSON (builtins.readFile ./flake.lock); - in - fetchTarball { - url = "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz"; - sha256 = lock.nodes.flake-compat.locked.narHash; - } - ) - {src = ./.;} -) -.defaultNix +(import ( + let + lock = builtins.fromJSON (builtins.readFile ./flake.lock); + in + fetchTarball { + url = "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz"; + sha256 = lock.nodes.flake-compat.locked.narHash; + } +) { src = ./.; }).defaultNix diff --git a/flake.nix b/flake.nix index 7cef5217a..1e3e36d66 100644 --- a/flake.nix +++ b/flake.nix @@ -2,8 +2,8 @@ description = "A custom launcher for Minecraft that allows you to easily manage multiple installations of Minecraft at once (Fork of MultiMC)"; nixConfig = { - extra-substituters = ["https://cache.garnix.io"]; - extra-trusted-public-keys = ["cache.garnix.io:CTFPyKSLcx5RMJKfLo5EEPUObbA78b0YQ2DTCJXqr9g="]; + extra-substituters = [ "https://cache.garnix.io" ]; + extra-trusted-public-keys = [ "cache.garnix.io:CTFPyKSLcx5RMJKfLo5EEPUObbA78b0YQ2DTCJXqr9g=" ]; }; inputs = { @@ -30,12 +30,9 @@ }; }; - outputs = { - flake-parts, - pre-commit-hooks, - ... - } @ inputs: - flake-parts.lib.mkFlake {inherit inputs;} { + outputs = + { flake-parts, pre-commit-hooks, ... }@inputs: + flake-parts.lib.mkFlake { inherit inputs; } { imports = [ pre-commit-hooks.flakeModule diff --git a/nix/README.md b/nix/README.md index f7923577f..8a0b9ba26 100644 --- a/nix/README.md +++ b/nix/README.md @@ -15,7 +15,6 @@ to temporarily enable it when using `nix` commands. Example (NixOS): ```nix -{...}: { nix.settings = { trusted-substituters = [ @@ -39,6 +38,7 @@ Example: { inputs = { nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + prismlauncher = { url = "github:PrismLauncher/PrismLauncher"; # Optional: Override the nixpkgs input of prismlauncher to use the same revision as the rest of your flake @@ -47,19 +47,24 @@ Example: }; }; - outputs = {nixpkgs, prismlauncher}: { - nixosConfigurations.foo = nixpkgs.lib.nixosSystem { - system = "x86_64-linux"; + outputs = + { nixpkgs, prismlauncher }: + { + nixosConfigurations.foo = nixpkgs.lib.nixosSystem { + modules = [ + ./configuration.nix - modules = [ - ({pkgs, ...}: { - nixpkgs.overlays = [prismlauncher.overlays.default]; + ( + { pkgs, ... }: + { + nixpkgs.overlays = [ prismlauncher.overlays.default ]; - environment.systemPackages = [pkgs.prismlauncher]; - }) - ]; + environment.systemPackages = [ pkgs.prismlauncher ]; + } + ) + ]; + }; }; - } } ``` @@ -74,6 +79,7 @@ Example: { inputs = { nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + prismlauncher = { url = "github:PrismLauncher/PrismLauncher"; # Optional: Override the nixpkgs input of prismlauncher to use the same revision as the rest of your flake @@ -82,17 +88,22 @@ Example: }; }; - outputs = {nixpkgs, prismlauncher}: { - nixosConfigurations.foo = nixpkgs.lib.nixosSystem { - system = "x86_64-linux"; + outputs = + { nixpkgs, prismlauncher }: + { + nixosConfigurations.foo = nixpkgs.lib.nixosSystem { + modules = [ + ./configuration.nix - modules = [ - ({pkgs, ...}: { - environment.systemPackages = [prismlauncher.packages.${pkgs.system}.prismlauncher]; - }) - ]; + ( + { pkgs, ... }: + { + environment.systemPackages = [ prismlauncher.packages.${pkgs.system}.prismlauncher ]; + } + ) + ]; + }; }; - } } ``` @@ -118,7 +129,6 @@ If you want to avoid rebuilds you may add the garnix cache to your substitutors. Example (NixOS): ```nix -{...}: { nix.settings = { trusted-substituters = [ @@ -139,10 +149,15 @@ We use flake-compat to allow using this Flake on a system that doesn't use flake Example: ```nix -{pkgs, ...}: { - nixpkgs.overlays = [(import (builtins.fetchTarball "https://github.com/PrismLauncher/PrismLauncher/archive/develop.tar.gz")).overlays.default]; +{ pkgs, ... }: +{ + nixpkgs.overlays = [ + (import ( + builtins.fetchTarball "https://github.com/PrismLauncher/PrismLauncher/archive/develop.tar.gz" + )).overlays.default + ]; - environment.systemPackages = [pkgs.prismlauncher]; + environment.systemPackages = [ pkgs.prismlauncher ]; } ``` @@ -154,8 +169,13 @@ This way the installed package is fully reproducible. Example: ```nix -{pkgs, ...}: { - environment.systemPackages = [(import (builtins.fetchTarball "https://github.com/PrismLauncher/PrismLauncher/archive/develop.tar.gz")).packages.${pkgs.system}.prismlauncher]; +{ pkgs, ... }: +{ + environment.systemPackages = [ + (import ( + builtins.fetchTarball "https://github.com/PrismLauncher/PrismLauncher/archive/develop.tar.gz" + )).packages.${pkgs.system}.prismlauncher + ]; } ``` diff --git a/nix/dev.nix b/nix/dev.nix index 22b4b43fb..2ae3c845b 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; - deadnix.enable = true; - nil.enable = true; - nixfmt.enable = true; + deadnix.enable = true; + nil.enable = true; + nixfmt.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} + ''; + + inputsFrom = [ config.packages.prismlauncher-unwrapped ]; + buildInputs = with pkgs; [ + ccache + ninja + ]; + }; + + formatter = pkgs.nixfmt-rfc-style; }; - - devShells.default = pkgs.mkShell { - shellHook = '' - ${config.pre-commit.installationScript} - ''; - - inputsFrom = [config.packages.prismlauncher-unwrapped]; - buildInputs = with pkgs; [ccache ninja]; - }; - - formatter = pkgs.nixfmt-rfc-style; - }; } diff --git a/nix/distribution.nix b/nix/distribution.nix index 28ef7ced1..ac7fc9871 100644 --- a/nix/distribution.nix +++ b/nix/distribution.nix @@ -1,37 +1,33 @@ +{ inputs, self, ... }: { - inputs, - self, - ... -}: { - perSystem = { - lib, - pkgs, - ... - }: { - packages = let - ourPackages = lib.fix (final: self.overlays.default final pkgs); - in { - inherit - (ourPackages) - prismlauncher-unwrapped - prismlauncher - ; - default = ourPackages.prismlauncher; + perSystem = + { lib, pkgs, ... }: + { + packages = + let + ourPackages = lib.fix (final: self.overlays.default final pkgs); + in + { + inherit (ourPackages) prismlauncher-unwrapped prismlauncher; + default = ourPackages.prismlauncher; + }; }; - }; flake = { - overlays.default = final: prev: let - version = builtins.substring 0 8 self.lastModifiedDate or "dirty"; - in { - prismlauncher-unwrapped = prev.callPackage ./pkg { - inherit (inputs) libnbtplusplus; - inherit version; - }; + overlays.default = + final: prev: + let + version = builtins.substring 0 8 self.lastModifiedDate or "dirty"; + in + { + prismlauncher-unwrapped = prev.callPackage ./pkg { + inherit (inputs) libnbtplusplus; + inherit version; + }; - prismlauncher = prev.qt6Packages.callPackage ./pkg/wrapper.nix { - inherit (final) prismlauncher-unwrapped; + prismlauncher = prev.qt6Packages.callPackage ./pkg/wrapper.nix { + inherit (final) prismlauncher-unwrapped; + }; }; - }; }; } diff --git a/nix/pkg/default.nix b/nix/pkg/default.nix index f3ff3789c..a5a57eaf0 100644 --- a/nix/pkg/default.nix +++ b/nix/pkg/default.nix @@ -18,16 +18,19 @@ version, libnbtplusplus, }: + assert lib.assertMsg ( gamemodeSupport -> stdenv.isLinux ) "gamemodeSupport is only available on Linux."; - stdenv.mkDerivation { - pname = "prismlauncher-unwrapped"; - inherit version; - src = lib.fileset.toSource { - root = ../../.; - fileset = lib.fileset.unions (map (fileName: ../../${fileName}) [ +stdenv.mkDerivation { + pname = "prismlauncher-unwrapped"; + inherit version; + + src = lib.fileset.toSource { + root = ../../.; + fileset = lib.fileset.unions ( + map (fileName: ../../${fileName}) [ "buildconfig" "cmake" "launcher" @@ -36,71 +39,70 @@ 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; + + 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/") ]; - 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; + dontWrapQtApps = true; - 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/") - ]; - - dontWrapQtApps = true; - - meta = { - description = "Free, open source launcher for Minecraft"; - 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://prismlauncher.org/"; - license = lib.licenses.gpl3Only; - maintainers = with lib.maintainers; [ - Scrumplex - getchoo - ]; - mainProgram = "prismlauncher"; - platforms = lib.platforms.linux ++ lib.platforms.darwin; - }; - } + meta = { + description = "Free, open source launcher for Minecraft"; + 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://prismlauncher.org/"; + license = lib.licenses.gpl3Only; + maintainers = with lib.maintainers; [ + Scrumplex + getchoo + ]; + mainProgram = "prismlauncher"; + platforms = lib.platforms.linux ++ lib.platforms.darwin; + }; +} diff --git a/nix/pkg/wrapper.nix b/nix/pkg/wrapper.nix index e7516397e..5632d483b 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 ? [ @@ -42,55 +42,60 @@ # itself can take slightly longer to start withWaylandGLFW ? false, }: + assert lib.assertMsg ( controllerSupport -> stdenv.isLinux ) "controllerSupport only has an effect on Linux."; + assert lib.assertMsg ( textToSpeechSupport -> stdenv.isLinux ) "textToSpeechSupport only has an effect on Linux."; + assert lib.assertMsg ( withWaylandGLFW -> stdenv.isLinux -) "withWaylandGLFW is only available on Linux."; let - prismlauncher' = prismlauncher-unwrapped.override {inherit msaClientID gamemodeSupport;}; +) "withWaylandGLFW is only available on Linux."; + +let + prismlauncher' = prismlauncher-unwrapped.override { inherit msaClientID gamemodeSupport; }; in - symlinkJoin { - name = "prismlauncher-${prismlauncher'.version}"; +symlinkJoin { + name = "prismlauncher-${prismlauncher'.version}"; - paths = [prismlauncher']; + paths = [ prismlauncher' ]; - 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 +120,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 PRISMLAUNCHER_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 PRISMLAUNCHER_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 - (prismlauncher'.meta) - description - longDescription - homepage - changelog - license - maintainers - mainProgram - platforms - ; - }; - } + meta = { + inherit (prismlauncher'.meta) + description + longDescription + homepage + changelog + license + maintainers + mainProgram + platforms + ; + }; +} From 7a83d0cea03648bd6cefc46f454f1166773aa87f Mon Sep 17 00:00:00 2001 From: seth Date: Tue, 20 Aug 2024 01:47:03 -0400 Subject: [PATCH 03/13] ci(nix): drop pre-commit-hooks Signed-off-by: seth --- flake.lock | 51 +-------------------------------------------------- flake.nix | 38 ++++++++++++++++++++++---------------- nix/dev.nix | 36 ++---------------------------------- 3 files changed, 25 insertions(+), 100 deletions(-) diff --git a/flake.lock b/flake.lock index 77e707692..3e9cd8e42 100644 --- a/flake.lock +++ b/flake.lock @@ -36,27 +36,6 @@ "type": "github" } }, - "gitignore": { - "inputs": { - "nixpkgs": [ - "pre-commit-hooks", - "nixpkgs" - ] - }, - "locked": { - "lastModified": 1709087332, - "narHash": "sha256-HG2cCnktfHsKV0s4XW83gU3F57gaTljL9KNSuG6bnQs=", - "owner": "hercules-ci", - "repo": "gitignore.nix", - "rev": "637db329424fd7e46cf4185293b9cc8c88c95394", - "type": "github" - }, - "original": { - "owner": "hercules-ci", - "repo": "gitignore.nix", - "type": "github" - } - }, "libnbtplusplus": { "flake": false, "locked": { @@ -89,40 +68,12 @@ "type": "github" } }, - "pre-commit-hooks": { - "inputs": { - "flake-compat": [ - "flake-compat" - ], - "gitignore": "gitignore", - "nixpkgs": [ - "nixpkgs" - ], - "nixpkgs-stable": [ - "nixpkgs" - ] - }, - "locked": { - "lastModified": 1723803910, - "narHash": "sha256-yezvUuFiEnCFbGuwj/bQcqg7RykIEqudOy/RBrId0pc=", - "owner": "cachix", - "repo": "pre-commit-hooks.nix", - "rev": "bfef0ada09e2c8ac55bbcd0831bd0c9d42e651ba", - "type": "github" - }, - "original": { - "owner": "cachix", - "repo": "pre-commit-hooks.nix", - "type": "github" - } - }, "root": { "inputs": { "flake-compat": "flake-compat", "flake-parts": "flake-parts", "libnbtplusplus": "libnbtplusplus", - "nixpkgs": "nixpkgs", - "pre-commit-hooks": "pre-commit-hooks" + "nixpkgs": "nixpkgs" } } }, diff --git a/flake.nix b/flake.nix index 1e3e36d66..d64874e30 100644 --- a/flake.nix +++ b/flake.nix @@ -12,30 +12,36 @@ url = "github:hercules-ci/flake-parts"; inputs.nixpkgs-lib.follows = "nixpkgs"; }; - pre-commit-hooks = { - url = "github:cachix/pre-commit-hooks.nix"; - inputs = { - nixpkgs.follows = "nixpkgs"; - nixpkgs-stable.follows = "nixpkgs"; - flake-compat.follows = "flake-compat"; - }; - }; - flake-compat = { - url = "github:edolstra/flake-compat"; - flake = false; - }; libnbtplusplus = { url = "github:PrismLauncher/libnbtplusplus"; flake = false; }; + + /* + Inputs below this are optional and can be removed + + ``` + { + inputs.prismlauncher = { + url = "github:PrismLauncher/PrismLauncher"; + inputs = { + flake-compat.follows = ""; + }; + }; + } + ``` + */ + + flake-compat = { + url = "github:edolstra/flake-compat"; + flake = false; + }; }; outputs = - { flake-parts, pre-commit-hooks, ... }@inputs: - flake-parts.lib.mkFlake { inherit inputs; } { + inputs: + inputs.flake-parts.lib.mkFlake { inherit inputs; } { imports = [ - pre-commit-hooks.flakeModule - ./nix/dev.nix ./nix/distribution.nix ]; diff --git a/nix/dev.nix b/nix/dev.nix index 2ae3c845b..32b1bd92b 100644 --- a/nix/dev.nix +++ b/nix/dev.nix @@ -1,41 +1,9 @@ { perSystem = + { pkgs, self', ... }: { - config, - lib, - pkgs, - ... - }: - { - pre-commit.settings = { - hooks = { - markdownlint.enable = true; - - deadnix.enable = true; - nil.enable = true; - nixfmt.enable = true; - - clang-format = { - enable = true; - types_or = [ - "c" - "c++" - "java" - "json" - "objective-c" - ]; - }; - }; - - tools.clang-tools = lib.mkForce pkgs.clang-tools_18; - }; - devShells.default = pkgs.mkShell { - shellHook = '' - ${config.pre-commit.installationScript} - ''; - - inputsFrom = [ config.packages.prismlauncher-unwrapped ]; + inputsFrom = [ self'.packages.prismlauncher-unwrapped ]; buildInputs = with pkgs; [ ccache ninja From 271c38bc568bc348186fb5c06a3f07f7646b2f24 Mon Sep 17 00:00:00 2001 From: seth Date: Tue, 20 Aug 2024 01:59:33 -0400 Subject: [PATCH 04/13] doc(nix): update package names and params Signed-off-by: seth --- nix/README.md | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/nix/README.md b/nix/README.md index 8a0b9ba26..2daeb73d3 100644 --- a/nix/README.md +++ b/nix/README.md @@ -197,18 +197,20 @@ nix-env -iA prismlauncher.prismlauncher Both Nixpkgs and this repository offer the following packages: -- `prismlauncher` - Preferred build using Qt 6 -- `prismlauncher-qt5` - Legacy build using Qt 5 (i.e. for Qt 5 theming support) - -Both of these packages also have `-unwrapped` counterparts, that are not wrapped and can therefore be customized even further than what the wrapper packages offer. +- `prismlauncher` - The preferred build, wrapped with everything necessary to run the launcher and Minecraft +- `prismlauncher-unwrapped` - A minimal build that allows for advanced customization of the launcher's runtime environment ### Customizing wrapped packages -The wrapped packages (`prismlauncher` and `prismlauncher-qt5`) offer some build parameters to further customize the launcher's environment. +The wrapped package (`prismlauncher`) offers some build parameters to further customize the launcher's environment. The following parameters can be overridden: -- `msaClientID` (default: `null`, requires full rebuild!) Client ID used for Microsoft Authentication -- `gamemodeSupport` (default: `true`) Turn on/off support for [Feral GameMode](https://github.com/FeralInteractive/gamemode) -- `jdks` (default: `[ jdk17 jdk8 ]`) Java runtimes added to `PRISMLAUNCHER_JAVA_PATHS` variable - `additionalLibs` (default: `[ ]`) Additional libraries that will be added to `LD_LIBRARY_PATH` +- `additionalPrograms` (default: `[ ]`) Additional libraries that will be added to `PATH` +- `controllerSupport` (default: `isLinux`) Turn on/off support for controllers on Linux (macOS will always have this) +- `gamemodeSupport` (default: `isLinux`) Turn on/off support for [Feral GameMode](https://github.com/FeralInteractive/gamemode) on Linux +- `jdks` (default: `[ jdk21 jdk17 jdk8 ]`) Java runtimes added to `PRISMLAUNCHER_JAVA_PATHS` variable +- `msaClientID` (default: `null`, requires full rebuild!) Client ID used for Microsoft Authentication +- `textToSpeechSupport` (default: `isLinux`) Turn on/off support for text-to-speech on Linux (macOS will always have this) +- `withWaylandGLFW` (default: `isLinux`) Build with support for native Wayland via a custom GLFW From e85b3647481f4af5638673837814c2f8835e4054 Mon Sep 17 00:00:00 2001 From: seth Date: Tue, 20 Aug 2024 02:04:05 -0400 Subject: [PATCH 05/13] refactor(nix): use `final` in overlay this allows to implictly pass `prismlauncher-unwrapped` it won't have an effect on our package set as directly inheriting from the scope we create filters out the extra attributes usually introduced with a scope Signed-off-by: seth --- nix/distribution.nix | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/nix/distribution.nix b/nix/distribution.nix index ac7fc9871..74e77da1b 100644 --- a/nix/distribution.nix +++ b/nix/distribution.nix @@ -5,7 +5,7 @@ { packages = let - ourPackages = lib.fix (final: self.overlays.default final pkgs); + ourPackages = lib.makeScope pkgs.newScope (final: self.overlays.default final pkgs); in { inherit (ourPackages) prismlauncher-unwrapped prismlauncher; @@ -25,9 +25,7 @@ inherit version; }; - prismlauncher = prev.qt6Packages.callPackage ./pkg/wrapper.nix { - inherit (final) prismlauncher-unwrapped; - }; + prismlauncher = final.callPackage ./pkg/wrapper.nix { }; }; }; } From 0ae421c265e665fc6621337b0c1216e548293690 Mon Sep 17 00:00:00 2001 From: seth Date: Tue, 20 Aug 2024 02:58:55 -0400 Subject: [PATCH 06/13] chore(nix): drop flake-parts The primary goals here include making the flake easier to contribute to by having it follow the standard boilerplate, while also limiting the size of our flake.lock to lower the chance of duplicate inputs for users Signed-off-by: seth --- flake.lock | 21 -------- flake.nix | 75 ++++++++++++++++++++------ nix/README.md | 10 +++- nix/dev.nix | 15 ------ nix/distribution.nix | 31 ----------- nix/{pkg/default.nix => unwrapped.nix} | 4 +- nix/{pkg => }/wrapper.nix | 0 7 files changed, 69 insertions(+), 87 deletions(-) delete mode 100644 nix/dev.nix delete mode 100644 nix/distribution.nix rename nix/{pkg/default.nix => unwrapped.nix} (97%) rename nix/{pkg => }/wrapper.nix (100%) diff --git a/flake.lock b/flake.lock index 3e9cd8e42..7d21aad14 100644 --- a/flake.lock +++ b/flake.lock @@ -16,26 +16,6 @@ "type": "github" } }, - "flake-parts": { - "inputs": { - "nixpkgs-lib": [ - "nixpkgs" - ] - }, - "locked": { - "lastModified": 1722555600, - "narHash": "sha256-XOQkdLafnb/p9ij77byFQjDf5m5QYl9b2REiVClC+x4=", - "owner": "hercules-ci", - "repo": "flake-parts", - "rev": "8471fe90ad337a8074e957b69ca4d0089218391d", - "type": "github" - }, - "original": { - "owner": "hercules-ci", - "repo": "flake-parts", - "type": "github" - } - }, "libnbtplusplus": { "flake": false, "locked": { @@ -71,7 +51,6 @@ "root": { "inputs": { "flake-compat": "flake-compat", - "flake-parts": "flake-parts", "libnbtplusplus": "libnbtplusplus", "nixpkgs": "nixpkgs" } diff --git a/flake.nix b/flake.nix index d64874e30..24227aca7 100644 --- a/flake.nix +++ b/flake.nix @@ -8,10 +8,7 @@ inputs = { nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; - flake-parts = { - url = "github:hercules-ci/flake-parts"; - inputs.nixpkgs-lib.follows = "nixpkgs"; - }; + libnbtplusplus = { url = "github:PrismLauncher/libnbtplusplus"; flake = false; @@ -39,18 +36,64 @@ }; outputs = - inputs: - inputs.flake-parts.lib.mkFlake { inherit inputs; } { - imports = [ - ./nix/dev.nix - ./nix/distribution.nix - ]; + { + self, + nixpkgs, + libnbtplusplus, + ... + }: + let + inherit (nixpkgs) lib; - systems = [ - "x86_64-linux" - "aarch64-linux" - "x86_64-darwin" - "aarch64-darwin" - ]; + # 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 + { + devShells = forAllSystems ( + system: + let + pkgs = nixpkgsFor.${system}; + in + { + default = pkgs.mkShell { + inputsFrom = [ self.packages.${system}.prismlauncher-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 + { + prismlauncher-unwrapped = prev.callPackage ./nix/unwrapped.nix { inherit libnbtplusplus version; }; + + prismlauncher = final.callPackage ./nix/wrapper.nix { }; + }; + + packages = forAllSystems ( + system: + let + pkgs = nixpkgsFor.${system}; + + prismPackages = lib.makeScope pkgs.newScope (final: self.overlays.default final pkgs); + in + { + inherit (prismPackages) prismlauncher-unwrapped prismlauncher; + default = prismPackages.prismlauncher; + } + ); }; } diff --git a/nix/README.md b/nix/README.md index 2daeb73d3..d6068a968 100644 --- a/nix/README.md +++ b/nix/README.md @@ -44,11 +44,14 @@ Example: # Optional: Override the nixpkgs input of prismlauncher to use the same revision as the rest of your flake # Note that overriding any input of prismlauncher may break reproducibility # inputs.nixpkgs.follows = "nixpkgs"; + + # This is not required for Flakes + inputs.flake-compat.follows = ""; }; }; outputs = - { nixpkgs, prismlauncher }: + { nixpkgs, prismlauncher, ... }: { nixosConfigurations.foo = nixpkgs.lib.nixosSystem { modules = [ @@ -85,11 +88,14 @@ Example: # Optional: Override the nixpkgs input of prismlauncher to use the same revision as the rest of your flake # Note that overriding any input of prismlauncher may break reproducibility # inputs.nixpkgs.follows = "nixpkgs"; + + # This is not required for Flakes + inputs.flake-compat.follows = ""; }; }; outputs = - { nixpkgs, prismlauncher }: + { nixpkgs, prismlauncher, ... }: { nixosConfigurations.foo = nixpkgs.lib.nixosSystem { modules = [ diff --git a/nix/dev.nix b/nix/dev.nix deleted file mode 100644 index 32b1bd92b..000000000 --- a/nix/dev.nix +++ /dev/null @@ -1,15 +0,0 @@ -{ - perSystem = - { pkgs, self', ... }: - { - devShells.default = pkgs.mkShell { - inputsFrom = [ self'.packages.prismlauncher-unwrapped ]; - buildInputs = with pkgs; [ - ccache - ninja - ]; - }; - - formatter = pkgs.nixfmt-rfc-style; - }; -} diff --git a/nix/distribution.nix b/nix/distribution.nix deleted file mode 100644 index 74e77da1b..000000000 --- a/nix/distribution.nix +++ /dev/null @@ -1,31 +0,0 @@ -{ inputs, self, ... }: -{ - perSystem = - { lib, pkgs, ... }: - { - packages = - let - ourPackages = lib.makeScope pkgs.newScope (final: self.overlays.default final pkgs); - in - { - inherit (ourPackages) prismlauncher-unwrapped prismlauncher; - default = ourPackages.prismlauncher; - }; - }; - - flake = { - overlays.default = - final: prev: - let - version = builtins.substring 0 8 self.lastModifiedDate or "dirty"; - in - { - prismlauncher-unwrapped = prev.callPackage ./pkg { - inherit (inputs) libnbtplusplus; - inherit version; - }; - - prismlauncher = final.callPackage ./pkg/wrapper.nix { }; - }; - }; -} diff --git a/nix/pkg/default.nix b/nix/unwrapped.nix similarity index 97% rename from nix/pkg/default.nix rename to nix/unwrapped.nix index a5a57eaf0..f007c05b8 100644 --- a/nix/pkg/default.nix +++ b/nix/unwrapped.nix @@ -28,9 +28,9 @@ stdenv.mkDerivation { inherit version; src = lib.fileset.toSource { - root = ../../.; + root = ../.; fileset = lib.fileset.unions ( - map (fileName: ../../${fileName}) [ + map (fileName: ../${fileName}) [ "buildconfig" "cmake" "launcher" diff --git a/nix/pkg/wrapper.nix b/nix/wrapper.nix similarity index 100% rename from nix/pkg/wrapper.nix rename to nix/wrapper.nix From e29ea4efb08d01bf64948370810a7963e7b72c5f Mon Sep 17 00:00:00 2001 From: seth Date: Tue, 20 Aug 2024 03:16:32 -0400 Subject: [PATCH 07/13] build(nix): add formatting checks Signed-off-by: seth --- flake.nix | 21 +++++++++++++++++---- nix/checks.nix | 42 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+), 4 deletions(-) create mode 100644 nix/checks.nix diff --git a/flake.nix b/flake.nix index 24227aca7..2fe36902a 100644 --- a/flake.nix +++ b/flake.nix @@ -54,6 +54,14 @@ 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 @@ -88,12 +96,17 @@ let pkgs = nixpkgsFor.${system}; + # Build a scope from our overlay prismPackages = lib.makeScope pkgs.newScope (final: self.overlays.default final pkgs); + + # Grab our packages from it and set the default + packages = { + inherit (prismPackages) prismlauncher-unwrapped prismlauncher; + default = prismPackages.prismlauncher; + }; in - { - inherit (prismPackages) prismlauncher-unwrapped prismlauncher; - default = prismPackages.prismlauncher; - } + # Only output them if they're available on the current system + lib.filterAttrs (_: lib.meta.availableOn pkgs.stdenv.hostPlatform) packages ); }; } diff --git a/nix/checks.nix b/nix/checks.nix new file mode 100644 index 000000000..40a2e272f --- /dev/null +++ b/nix/checks.nix @@ -0,0 +1,42 @@ +{ + runCommand, + deadnix, + llvmPackages_18, + markdownlint-cli, + nixfmt-rfc-style, + statix, + self, +}: +{ + formatting = + runCommand "check-formatting" + { + nativeBuildInputs = [ + deadnix + llvmPackages_18.clang-tools + markdownlint-cli + nixfmt-rfc-style + statix + ]; + } + '' + cd ${self} + + echo "Running clang-format...." + clang-format -i --style='file' --Werror */**.{c,cc,cpp,h,hh,hpp} + + echo "Running deadnix..." + deadnix --fail + + echo "Running markdownlint..." + markdownlint --dot . + + echo "Running nixfmt..." + nixfmt --check . + + echo "Running statix" + statix check . + + touch $out + ''; +} From 13eedbb7de4f6bbc80308aa59745720c3cf7c33d Mon Sep 17 00:00:00 2001 From: seth Date: Tue, 20 Aug 2024 03:41:53 -0400 Subject: [PATCH 08/13] doc(nix): prefer `packages` output overlays can cause issues we don't run into upstream, especially when used on stable channels for example. preferring the pure `packages` output also encourages the use of our binary cache by users, who probably don't like building the launcher all too much Signed-off-by: seth --- nix/README.md | 136 ++++++++++++++++++++++++++------------------------ 1 file changed, 72 insertions(+), 64 deletions(-) diff --git a/nix/README.md b/nix/README.md index d6068a968..76cb8bf27 100644 --- a/nix/README.md +++ b/nix/README.md @@ -28,9 +28,9 @@ Example (NixOS): } ``` -### Using the overlay +### Installing the package directly -After adding `github:PrismLauncher/PrismLauncher` to your flake inputs, you can add the `default` overlay to your nixpkgs instance. +After adding `github:PrismLauncher/PrismLauncher` to your flake inputs, you can access the flake's `packages` output. Example: @@ -41,8 +41,58 @@ Example: prismlauncher = { url = "github:PrismLauncher/PrismLauncher"; + # Optional: Override the nixpkgs input of prismlauncher to use the same revision as the rest of your flake - # Note that overriding any input of prismlauncher may break reproducibility + # Note that this may break the reproducibility mentioned above, and you might not be able to access the binary cache + # + # inputs.nixpkgs.follows = "nixpkgs"; + + # This is not required for Flakes + inputs.flake-compat.follows = ""; + }; + }; + + outputs = + { nixpkgs, prismlauncher, ... }: + { + nixosConfigurations.foo = nixpkgs.lib.nixosSystem { + modules = [ + ./configuration.nix + + ( + { pkgs, ... }: + { + environment.systemPackages = [ prismlauncher.packages.${pkgs.system}.prismlauncher ]; + } + ) + ]; + }; + }; +} +``` + +### Using the overlay + +Alternatively, if you don't want to use our `packages` output, you can add our overlay to your nixpkgs instance. +This will ensure Prism is built with your system's packages. + +> [!WARNING] +> Depending on what revision of nixpkgs your system uses, this may result in binaries that differ from the above `packages` output +> If this is the case, you will not be able to use the binary cache + +Example: + +```nix +{ + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + + prismlauncher = { + url = "github:PrismLauncher/PrismLauncher"; + + # Optional: Override the nixpkgs input of prismlauncher to use the same revision as the rest of your flake + # Note that this may break the reproducibility mentioned above, and you might not be able to access the binary cache + # # inputs.nixpkgs.follows = "nixpkgs"; # This is not required for Flakes @@ -71,48 +121,6 @@ Example: } ``` -### Installing the package directly - -Alternatively, if you don't want to use an overlay, you can install Prism Launcher directly by installing the `prismlauncher` package. -This way the installed package is fully reproducible. - -Example: - -```nix -{ - inputs = { - nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; - - prismlauncher = { - url = "github:PrismLauncher/PrismLauncher"; - # Optional: Override the nixpkgs input of prismlauncher to use the same revision as the rest of your flake - # Note that overriding any input of prismlauncher may break reproducibility - # inputs.nixpkgs.follows = "nixpkgs"; - - # This is not required for Flakes - inputs.flake-compat.follows = ""; - }; - }; - - outputs = - { nixpkgs, prismlauncher, ... }: - { - nixosConfigurations.foo = nixpkgs.lib.nixosSystem { - modules = [ - ./configuration.nix - - ( - { pkgs, ... }: - { - environment.systemPackages = [ prismlauncher.packages.${pkgs.system}.prismlauncher ]; - } - ) - ]; - }; - }; -} -``` - ### Installing the package ad-hoc (`nix shell`, `nix run`, etc.) You can simply call the default package of this flake. @@ -148,12 +156,30 @@ Example (NixOS): } ``` -### Using the overlay (`fetchTarball`) +### Installing the package directly (`fetchTarball`) We use flake-compat to allow using this Flake on a system that doesn't use flakes. Example: +```nix +{ pkgs, ... }: +{ + environment.systemPackages = [ + (import ( + builtins.fetchTarball "https://github.com/PrismLauncher/PrismLauncher/archive/develop.tar.gz" + )).packages.${pkgs.system}.prismlauncher + ]; +} +``` + +### Using the overlay (`fetchTarball`) + +Alternatively, if you don't want to use our `packages` output, you can add our overlay to your instance of nixpkgs. +This results in Prism using your system's libraries + +Example: + ```nix { pkgs, ... }: { @@ -167,24 +193,6 @@ Example: } ``` -### Installing the package directly (`fetchTarball`) - -Alternatively, if you don't want to use an overlay, you can install Prism Launcher directly by installing the `prismlauncher` package. -This way the installed package is fully reproducible. - -Example: - -```nix -{ pkgs, ... }: -{ - environment.systemPackages = [ - (import ( - builtins.fetchTarball "https://github.com/PrismLauncher/PrismLauncher/archive/develop.tar.gz" - )).packages.${pkgs.system}.prismlauncher - ]; -} -``` - ### Installing the package ad-hoc (`nix-env`) You can add this repository as a channel and install its packages that way. From a49a58bc4571f87f42f45bb9eeb1a957d5d12331 Mon Sep 17 00:00:00 2001 From: seth Date: Wed, 21 Aug 2024 03:42:40 -0400 Subject: [PATCH 09/13] Revert "refactor(nix): nix-filter -> lib.fileset" This reverts commit 8312713dc2274670db6f9167125af8a27c2fd8a6. See nix#9428. Path coercion like `"${./.}"` in flakes causes the path to be copied to the store twice; using the `self` argument works around this. However, as `lib.fileset` doesn't support using `self`, so we need to go back to `nix-filter` Signed-off-by: seth --- flake.lock | 16 ++++++++++++++++ flake.nix | 12 +++++++++++- nix/unwrapped.nix | 28 ++++++++++++++-------------- 3 files changed, 41 insertions(+), 15 deletions(-) diff --git a/flake.lock b/flake.lock index 7d21aad14..3210dc4e2 100644 --- a/flake.lock +++ b/flake.lock @@ -32,6 +32,21 @@ "type": "github" } }, + "nix-filter": { + "locked": { + "lastModified": 1710156097, + "narHash": "sha256-1Wvk8UP7PXdf8bCCaEoMnOT1qe5/Duqgj+rL8sRQsSM=", + "owner": "numtide", + "repo": "nix-filter", + "rev": "3342559a24e85fc164b295c3444e8a139924675b", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "nix-filter", + "type": "github" + } + }, "nixpkgs": { "locked": { "lastModified": 1723637854, @@ -52,6 +67,7 @@ "inputs": { "flake-compat": "flake-compat", "libnbtplusplus": "libnbtplusplus", + "nix-filter": "nix-filter", "nixpkgs": "nixpkgs" } } diff --git a/flake.nix b/flake.nix index 2fe36902a..987fc0eda 100644 --- a/flake.nix +++ b/flake.nix @@ -14,6 +14,8 @@ flake = false; }; + nix-filter.url = "github:numtide/nix-filter"; + /* Inputs below this are optional and can be removed @@ -40,6 +42,7 @@ self, nixpkgs, libnbtplusplus, + nix-filter, ... }: let @@ -86,7 +89,14 @@ version = builtins.substring 0 8 self.lastModifiedDate or "dirty"; in { - prismlauncher-unwrapped = prev.callPackage ./nix/unwrapped.nix { inherit libnbtplusplus version; }; + prismlauncher-unwrapped = prev.callPackage ./nix/unwrapped.nix { + inherit + libnbtplusplus + nix-filter + self + version + ; + }; prismlauncher = final.callPackage ./nix/wrapper.nix { }; }; diff --git a/nix/unwrapped.nix b/nix/unwrapped.nix index f007c05b8..f75acf1de 100644 --- a/nix/unwrapped.nix +++ b/nix/unwrapped.nix @@ -10,6 +10,8 @@ jdk17, kdePackages, ninja, + nix-filter, + self, stripJavaArchivesHook, tomlplusplus, zlib, @@ -27,20 +29,18 @@ stdenv.mkDerivation { pname = "prismlauncher-unwrapped"; inherit version; - src = lib.fileset.toSource { - root = ../.; - fileset = lib.fileset.unions ( - map (fileName: ../${fileName}) [ - "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 = '' From 99ecab01fc8e5217c95c45263a224e92bf5566ed Mon Sep 17 00:00:00 2001 From: seth Date: Wed, 21 Aug 2024 04:02:48 -0400 Subject: [PATCH 10/13] ci(garnix): explicitly declare systems as we now create outputs for each system in `lib.systems.flakeExposed`, we should ensure garnix only builds the systems we officially support dev shells are also no longer built as they really don't need to be "built" on the developer's machine in any case; everything should be cached Signed-off-by: seth --- garnix.yaml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/garnix.yaml b/garnix.yaml index 6cf8f7214..a7c1b48a9 100644 --- a/garnix.yaml +++ b/garnix.yaml @@ -1,7 +1,10 @@ builds: exclude: + # Currently broken on Garnix's end - "*.x86_64-darwin.*" include: - "checks.x86_64-linux.*" - - "devShells.*.*" - - "packages.*.*" + - "packages.x86_64-linux.*" + - "packages.aarch64-linux.*" + - "packages.x86_64-darwin.*" + - "packages.aarch64-darwin.*" From d2304b669872a5bc426a855cf2ee10dd40337808 Mon Sep 17 00:00:00 2001 From: TheKodeToad Date: Sat, 24 Aug 2024 22:10:38 +0100 Subject: [PATCH 11/13] Improve Java checking speed by using startsWith for gentoo paths Signed-off-by: TheKodeToad --- launcher/java/JavaUtils.cpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/launcher/java/JavaUtils.cpp b/launcher/java/JavaUtils.cpp index e82216fd4..bc8026348 100644 --- a/launcher/java/JavaUtils.cpp +++ b/launcher/java/JavaUtils.cpp @@ -403,12 +403,17 @@ QList JavaUtils::FindJavaPaths() { QList javas; javas.append(this->GetDefaultJava()->path); - auto scanJavaDir = [&](const QString& dirPath) { + auto scanJavaDir = [&]( + const QString& dirPath, + const std::function& filter = [](const QFileInfo&) { return true; }) { QDir dir(dirPath); if (!dir.exists()) return; auto entries = dir.entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot); for (auto& entry : entries) { + if (!filter(entry)) + continue; + QString prefix; prefix = entry.canonicalFilePath(); javas.append(FS::PathCombine(prefix, "jre/bin/java")); @@ -431,9 +436,13 @@ QList JavaUtils::FindJavaPaths() scanJavaDirs("/usr/lib64/jvm"); scanJavaDirs("/usr/lib32/jvm"); // Gentoo's locations for openjdk and openjdk-bin respectively - scanJavaDir("/usr/lib64"); - scanJavaDir("/usr/lib"); - scanJavaDir("/opt"); + auto gentooFilter = [](const QFileInfo& info) { + QString fileName = info.fileName(); + return fileName.startsWith("openjdk-") || fileName.startsWith("openj9-"); + }; + scanJavaDir("/usr/lib64", gentooFilter); + scanJavaDir("/usr/lib", gentooFilter); + scanJavaDir("/opt", gentooFilter); // javas stored in Prism Launcher's folder scanJavaDirs("java"); // manually installed JDKs in /opt From cbdacf81eea15e1383619cbd0043517509d42f6d Mon Sep 17 00:00:00 2001 From: TheKodeToad Date: Sat, 24 Aug 2024 22:50:51 +0100 Subject: [PATCH 12/13] Fix system theme detection Signed-off-by: TheKodeToad --- launcher/ui/themes/SystemTheme.cpp | 6 +++--- launcher/ui/themes/SystemTheme.h | 2 +- launcher/ui/themes/ThemeManager.cpp | 18 ++++++++++-------- launcher/ui/themes/ThemeManager.h | 3 ++- 4 files changed, 16 insertions(+), 13 deletions(-) diff --git a/launcher/ui/themes/SystemTheme.cpp b/launcher/ui/themes/SystemTheme.cpp index 791df2ed4..a1674455a 100644 --- a/launcher/ui/themes/SystemTheme.cpp +++ b/launcher/ui/themes/SystemTheme.cpp @@ -40,11 +40,11 @@ #include "HintOverrideProxyStyle.h" #include "ThemeManager.h" -SystemTheme::SystemTheme(QString& styleName, bool isSystemTheme) +SystemTheme::SystemTheme(const QString& styleName, const QPalette& palette, bool isDefaultTheme) { - themeName = isSystemTheme ? "system" : styleName; + themeName = isDefaultTheme ? "system" : styleName; widgetTheme = styleName; - colorPalette = QApplication::palette(); + colorPalette = palette; } void SystemTheme::apply(bool initial) diff --git a/launcher/ui/themes/SystemTheme.h b/launcher/ui/themes/SystemTheme.h index 783f2e4c2..7c260fdc4 100644 --- a/launcher/ui/themes/SystemTheme.h +++ b/launcher/ui/themes/SystemTheme.h @@ -38,7 +38,7 @@ class SystemTheme : public ITheme { public: - SystemTheme(QString& themeName, bool isSystemTheme = false); + SystemTheme(const QString& styleName, const QPalette& palette, bool isDefaultTheme); virtual ~SystemTheme() {} void apply(bool initial) override; diff --git a/launcher/ui/themes/ThemeManager.cpp b/launcher/ui/themes/ThemeManager.cpp index ad9a6f88e..691a51668 100644 --- a/launcher/ui/themes/ThemeManager.cpp +++ b/launcher/ui/themes/ThemeManager.cpp @@ -36,6 +36,13 @@ ThemeManager::ThemeManager() { + themeDebugLog() << "Determining System Widget Theme..."; + const auto& style = QApplication::style(); + m_defaultStyle = style->objectName(); + themeDebugLog() << "System theme seems to be:" << m_defaultStyle; + + m_defaultPalette = QApplication::palette(); + initializeThemes(); initializeCatPacks(); } @@ -121,13 +128,8 @@ void ThemeManager::initializeIcons() void ThemeManager::initializeWidgets() { - themeDebugLog() << "Determining System Widget Theme..."; - const auto& style = QApplication::style(); - m_currentlySelectedSystemTheme = style->objectName(); - themeDebugLog() << "System theme seems to be:" << m_currentlySelectedSystemTheme; - themeDebugLog() << "<> Initializing Widget Themes"; - themeDebugLog() << "Loading Built-in Theme:" << addTheme(std::make_unique(m_currentlySelectedSystemTheme, true)); + themeDebugLog() << "Loading Built-in Theme:" << addTheme(std::make_unique(m_defaultStyle, m_defaultPalette, true)); auto darkThemeId = addTheme(std::make_unique()); themeDebugLog() << "Loading Built-in Theme:" << darkThemeId; themeDebugLog() << "Loading Built-in Theme:" << addTheme(std::make_unique()); @@ -140,7 +142,7 @@ void ThemeManager::initializeWidgets() continue; } #endif - themeDebugLog() << "Loading System Theme:" << addTheme(std::make_unique(st)); + themeDebugLog() << "Loading System Theme:" << addTheme(std::make_unique(st, m_defaultPalette, false)); } // TODO: need some way to differentiate same name themes in different subdirectories @@ -260,7 +262,7 @@ void ThemeManager::applyCurrentlySelectedTheme(bool initial) themeDebugLog() << "<> Icon theme set."; auto applicationTheme = settings->get("ApplicationTheme").toString(); if (applicationTheme == "") { - applicationTheme = m_currentlySelectedSystemTheme; + applicationTheme = m_defaultStyle; } setApplicationTheme(applicationTheme, initial); themeDebugLog() << "<> Application theme set."; diff --git a/launcher/ui/themes/ThemeManager.h b/launcher/ui/themes/ThemeManager.h index 8bbcd34a9..c7e32bc8c 100644 --- a/launcher/ui/themes/ThemeManager.h +++ b/launcher/ui/themes/ThemeManager.h @@ -66,7 +66,8 @@ class ThemeManager { QDir m_applicationThemeFolder{ "themes" }; QDir m_catPacksFolder{ "catpacks" }; std::map> m_catPacks; - QString m_currentlySelectedSystemTheme; + QString m_defaultStyle; + QPalette m_defaultPalette; LogColors m_logColors; void initializeThemes(); From 5f874330d50cd497decc5ca708d539de9df6b616 Mon Sep 17 00:00:00 2001 From: Rachel Powers <508861+Ryex@users.noreply.github.com> Date: Sat, 24 Aug 2024 20:24:35 -0700 Subject: [PATCH 13/13] security(modrinth) reorder hash algo priority, prefer stronger hashes. Signed-off-by: Rachel Powers <508861+Ryex@users.noreply.github.com> --- .../modrinth/ModrinthInstanceCreationTask.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/launcher/modplatform/modrinth/ModrinthInstanceCreationTask.cpp b/launcher/modplatform/modrinth/ModrinthInstanceCreationTask.cpp index c0806a638..bf224412e 100644 --- a/launcher/modplatform/modrinth/ModrinthInstanceCreationTask.cpp +++ b/launcher/modplatform/modrinth/ModrinthInstanceCreationTask.cpp @@ -348,14 +348,14 @@ bool ModrinthCreationTask::parseManifest(const QString& index_path, QJsonObject hashes = Json::requireObject(modInfo, "hashes"); QString hash; QCryptographicHash::Algorithm hashAlgorithm; - hash = Json::ensureString(hashes, "sha1"); - hashAlgorithm = QCryptographicHash::Sha1; + hash = Json::ensureString(hashes, "sha512"); + hashAlgorithm = QCryptographicHash::Sha512; if (hash.isEmpty()) { - hash = Json::ensureString(hashes, "sha512"); - hashAlgorithm = QCryptographicHash::Sha512; + hash = Json::ensureString(hashes, "sha256"); + hashAlgorithm = QCryptographicHash::Sha256; if (hash.isEmpty()) { - hash = Json::ensureString(hashes, "sha256"); - hashAlgorithm = QCryptographicHash::Sha256; + hash = Json::ensureString(hashes, "sha1"); + hashAlgorithm = QCryptographicHash::Sha1; if (hash.isEmpty()) { throw JSONValidationError("No hash found for: " + file.path); }