style(nix): format with nixfmt

Signed-off-by: seth <getchoo@tuta.io>
This commit is contained in:
seth 2024-08-20 01:44:24 -04:00
parent 7dff77ca35
commit 4c81d8c53d
No known key found for this signature in database
GPG Key ID: D31BD0D494BBEE86
7 changed files with 259 additions and 236 deletions

View File

@ -1,14 +1,9 @@
( (import (
import let
( lock = builtins.fromJSON (builtins.readFile ./flake.lock);
let in
lock = builtins.fromJSON (builtins.readFile ./flake.lock); fetchTarball {
in url = "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz";
fetchTarball { sha256 = lock.nodes.flake-compat.locked.narHash;
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
}
)
{src = ./.;}
)
.defaultNix

View File

@ -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)"; description = "A custom launcher for Minecraft that allows you to easily manage multiple installations of Minecraft at once (Fork of MultiMC)";
nixConfig = { nixConfig = {
extra-substituters = ["https://cache.garnix.io"]; extra-substituters = [ "https://cache.garnix.io" ];
extra-trusted-public-keys = ["cache.garnix.io:CTFPyKSLcx5RMJKfLo5EEPUObbA78b0YQ2DTCJXqr9g="]; extra-trusted-public-keys = [ "cache.garnix.io:CTFPyKSLcx5RMJKfLo5EEPUObbA78b0YQ2DTCJXqr9g=" ];
}; };
inputs = { inputs = {
@ -30,12 +30,9 @@
}; };
}; };
outputs = { outputs =
flake-parts, { flake-parts, pre-commit-hooks, ... }@inputs:
pre-commit-hooks, flake-parts.lib.mkFlake { inherit inputs; } {
...
} @ inputs:
flake-parts.lib.mkFlake {inherit inputs;} {
imports = [ imports = [
pre-commit-hooks.flakeModule pre-commit-hooks.flakeModule

View File

@ -15,7 +15,6 @@ to temporarily enable it when using `nix` commands.
Example (NixOS): Example (NixOS):
```nix ```nix
{...}:
{ {
nix.settings = { nix.settings = {
trusted-substituters = [ trusted-substituters = [
@ -39,6 +38,7 @@ Example:
{ {
inputs = { inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
prismlauncher = { prismlauncher = {
url = "github:PrismLauncher/PrismLauncher"; url = "github:PrismLauncher/PrismLauncher";
# Optional: Override the nixpkgs input of prismlauncher to use the same revision as the rest of your flake # 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}: { outputs =
nixosConfigurations.foo = nixpkgs.lib.nixosSystem { { nixpkgs, prismlauncher }:
system = "x86_64-linux"; {
nixosConfigurations.foo = nixpkgs.lib.nixosSystem {
modules = [
./configuration.nix
modules = [ (
({pkgs, ...}: { { pkgs, ... }:
nixpkgs.overlays = [prismlauncher.overlays.default]; {
nixpkgs.overlays = [ prismlauncher.overlays.default ];
environment.systemPackages = [pkgs.prismlauncher]; environment.systemPackages = [ pkgs.prismlauncher ];
}) }
]; )
];
};
}; };
}
} }
``` ```
@ -74,6 +79,7 @@ Example:
{ {
inputs = { inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
prismlauncher = { prismlauncher = {
url = "github:PrismLauncher/PrismLauncher"; url = "github:PrismLauncher/PrismLauncher";
# Optional: Override the nixpkgs input of prismlauncher to use the same revision as the rest of your flake # 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}: { outputs =
nixosConfigurations.foo = nixpkgs.lib.nixosSystem { { nixpkgs, prismlauncher }:
system = "x86_64-linux"; {
nixosConfigurations.foo = nixpkgs.lib.nixosSystem {
modules = [
./configuration.nix
modules = [ (
({pkgs, ...}: { { pkgs, ... }:
environment.systemPackages = [prismlauncher.packages.${pkgs.system}.prismlauncher]; {
}) 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): Example (NixOS):
```nix ```nix
{...}:
{ {
nix.settings = { nix.settings = {
trusted-substituters = [ trusted-substituters = [
@ -139,10 +149,15 @@ We use flake-compat to allow using this Flake on a system that doesn't use flake
Example: Example:
```nix ```nix
{pkgs, ...}: { { pkgs, ... }:
nixpkgs.overlays = [(import (builtins.fetchTarball "https://github.com/PrismLauncher/PrismLauncher/archive/develop.tar.gz")).overlays.default]; {
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: Example:
```nix ```nix
{pkgs, ...}: { { pkgs, ... }:
environment.systemPackages = [(import (builtins.fetchTarball "https://github.com/PrismLauncher/PrismLauncher/archive/develop.tar.gz")).packages.${pkgs.system}.prismlauncher]; {
environment.systemPackages = [
(import (
builtins.fetchTarball "https://github.com/PrismLauncher/PrismLauncher/archive/develop.tar.gz"
)).packages.${pkgs.system}.prismlauncher
];
} }
``` ```

View File

@ -1,36 +1,47 @@
{ {
perSystem = { perSystem =
config, {
lib, config,
pkgs, lib,
... pkgs,
}: { ...
pre-commit.settings = { }:
hooks = { {
markdownlint.enable = true; pre-commit.settings = {
hooks = {
markdownlint.enable = true;
deadnix.enable = true; deadnix.enable = true;
nil.enable = true; nil.enable = true;
nixfmt.enable = true; nixfmt.enable = true;
clang-format = { clang-format = {
enable = true; enable = true;
types_or = ["c" "c++" "java" "json" "objective-c"]; 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;
};
} }

View File

@ -1,37 +1,33 @@
{ inputs, self, ... }:
{ {
inputs, perSystem =
self, { lib, pkgs, ... }:
... {
}: { packages =
perSystem = { let
lib, ourPackages = lib.fix (final: self.overlays.default final pkgs);
pkgs, in
... {
}: { inherit (ourPackages) prismlauncher-unwrapped prismlauncher;
packages = let default = ourPackages.prismlauncher;
ourPackages = lib.fix (final: self.overlays.default final pkgs); };
in {
inherit
(ourPackages)
prismlauncher-unwrapped
prismlauncher
;
default = ourPackages.prismlauncher;
}; };
};
flake = { flake = {
overlays.default = final: prev: let overlays.default =
version = builtins.substring 0 8 self.lastModifiedDate or "dirty"; final: prev:
in { let
prismlauncher-unwrapped = prev.callPackage ./pkg { version = builtins.substring 0 8 self.lastModifiedDate or "dirty";
inherit (inputs) libnbtplusplus; in
inherit version; {
}; prismlauncher-unwrapped = prev.callPackage ./pkg {
inherit (inputs) libnbtplusplus;
inherit version;
};
prismlauncher = prev.qt6Packages.callPackage ./pkg/wrapper.nix { prismlauncher = prev.qt6Packages.callPackage ./pkg/wrapper.nix {
inherit (final) prismlauncher-unwrapped; inherit (final) prismlauncher-unwrapped;
};
}; };
};
}; };
} }

View File

@ -18,16 +18,19 @@
version, version,
libnbtplusplus, libnbtplusplus,
}: }:
assert lib.assertMsg ( assert lib.assertMsg (
gamemodeSupport -> stdenv.isLinux gamemodeSupport -> stdenv.isLinux
) "gamemodeSupport is only available on Linux."; ) "gamemodeSupport is only available on Linux.";
stdenv.mkDerivation {
pname = "prismlauncher-unwrapped";
inherit version;
src = lib.fileset.toSource { stdenv.mkDerivation {
root = ../../.; pname = "prismlauncher-unwrapped";
fileset = lib.fileset.unions (map (fileName: ../../${fileName}) [ inherit version;
src = lib.fileset.toSource {
root = ../../.;
fileset = lib.fileset.unions (
map (fileName: ../../${fileName}) [
"buildconfig" "buildconfig"
"cmake" "cmake"
"launcher" "launcher"
@ -36,71 +39,70 @@ assert lib.assertMsg (
"tests" "tests"
"COPYING.md" "COPYING.md"
"CMakeLists.txt" "CMakeLists.txt"
]); ]
}; );
};
postUnpack = '' postUnpack = ''
rm -rf source/libraries/libnbtplusplus rm -rf source/libraries/libnbtplusplus
ln -s ${libnbtplusplus} source/libraries/libnbtplusplus ln -s ${libnbtplusplus} source/libraries/libnbtplusplus
''; '';
nativeBuildInputs = [ nativeBuildInputs = [
cmake cmake
ninja ninja
extra-cmake-modules extra-cmake-modules
jdk17 jdk17
stripJavaArchivesHook 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 = dontWrapQtApps = true;
[
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"]; meta = {
description = "Free, open source launcher for Minecraft";
cmakeFlags = longDescription = ''
[ Allows you to have multiple, separate instances of Minecraft (each with
(lib.cmakeFeature "Launcher_BUILD_PLATFORM" "nixpkgs") their own mods, texture packs, saves, etc) and helps you manage them and
] their associated options with a simple interface.
++ lib.optionals (msaClientID != null) [ '';
(lib.cmakeFeature "Launcher_MSA_CLIENT_ID" (toString msaClientID)) homepage = "https://prismlauncher.org/";
] license = lib.licenses.gpl3Only;
++ lib.optionals (lib.versionOlder kdePackages.qtbase.version "6") [ maintainers = with lib.maintainers; [
(lib.cmakeFeature "Launcher_QT_VERSION_MAJOR" "5") Scrumplex
] getchoo
++ lib.optionals stdenv.isDarwin [ ];
# we wrap our binary manually mainProgram = "prismlauncher";
(lib.cmakeFeature "INSTALL_BUNDLE" "nodeps") platforms = lib.platforms.linux ++ lib.platforms.darwin;
# 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;
};
}

View File

@ -22,8 +22,8 @@
udev, udev,
vulkan-loader, vulkan-loader,
xorg, xorg,
additionalLibs ? [], additionalLibs ? [ ],
additionalPrograms ? [], additionalPrograms ? [ ],
controllerSupport ? stdenv.isLinux, controllerSupport ? stdenv.isLinux,
gamemodeSupport ? stdenv.isLinux, gamemodeSupport ? stdenv.isLinux,
jdks ? [ jdks ? [
@ -42,55 +42,60 @@
# itself can take slightly longer to start # itself can take slightly longer to start
withWaylandGLFW ? false, withWaylandGLFW ? false,
}: }:
assert lib.assertMsg ( assert lib.assertMsg (
controllerSupport -> stdenv.isLinux controllerSupport -> stdenv.isLinux
) "controllerSupport only has an effect on Linux."; ) "controllerSupport only has an effect on Linux.";
assert lib.assertMsg ( assert lib.assertMsg (
textToSpeechSupport -> stdenv.isLinux textToSpeechSupport -> stdenv.isLinux
) "textToSpeechSupport only has an effect on Linux."; ) "textToSpeechSupport only has an effect on Linux.";
assert lib.assertMsg ( assert lib.assertMsg (
withWaylandGLFW -> stdenv.isLinux withWaylandGLFW -> stdenv.isLinux
) "withWaylandGLFW is only available on Linux."; let ) "withWaylandGLFW is only available on Linux.";
prismlauncher' = prismlauncher-unwrapped.override {inherit msaClientID gamemodeSupport;};
let
prismlauncher' = prismlauncher-unwrapped.override { inherit msaClientID gamemodeSupport; };
in in
symlinkJoin { symlinkJoin {
name = "prismlauncher-${prismlauncher'.version}"; name = "prismlauncher-${prismlauncher'.version}";
paths = [prismlauncher']; paths = [ prismlauncher' ];
nativeBuildInputs = nativeBuildInputs =
[kdePackages.wrapQtAppsHook] [ kdePackages.wrapQtAppsHook ]
# purposefully using a shell wrapper here for variable expansion # purposefully using a shell wrapper here for variable expansion
# see https://github.com/NixOS/nixpkgs/issues/172583 # see https://github.com/NixOS/nixpkgs/issues/172583
++ lib.optional withWaylandGLFW makeWrapper; ++ lib.optional withWaylandGLFW makeWrapper;
buildInputs = buildInputs =
[ [
kdePackages.qtbase kdePackages.qtbase
kdePackages.qtsvg kdePackages.qtsvg
] ]
++ lib.optional ( ++ lib.optional (
lib.versionAtLeast kdePackages.qtbase.version "6" && stdenv.isLinux lib.versionAtLeast kdePackages.qtbase.version "6" && stdenv.isLinux
) ) kdePackages.qtwayland;
kdePackages.qtwayland;
env = { env = {
waylandPreExec = lib.optionalString withWaylandGLFW '' waylandPreExec = lib.optionalString withWaylandGLFW ''
if [ -n "$WAYLAND_DISPLAY" ]; then if [ -n "$WAYLAND_DISPLAY" ]; then
export LD_LIBRARY_PATH=${lib.getLib glfw-wayland-minecraft}/lib:"$LD_LIBRARY_PATH" export LD_LIBRARY_PATH=${lib.getLib glfw-wayland-minecraft}/lib:"$LD_LIBRARY_PATH"
fi fi
''; '';
}; };
postBuild = postBuild =
lib.optionalString withWaylandGLFW '' lib.optionalString withWaylandGLFW ''
qtWrapperArgs+=(--run "$waylandPreExec") qtWrapperArgs+=(--run "$waylandPreExec")
'' ''
+ '' + ''
wrapQtAppsHook wrapQtAppsHook
''; '';
qtWrapperArgs = let qtWrapperArgs =
let
runtimeLibs = runtimeLibs =
[ [
# lwjgl # lwjgl
@ -115,31 +120,28 @@ in
++ lib.optional controllerSupport libusb1 ++ lib.optional controllerSupport libusb1
++ additionalLibs; ++ additionalLibs;
runtimePrograms = runtimePrograms = [
[ glxinfo
glxinfo pciutils # need lspci
pciutils # need lspci xorg.xrandr # needed for LWJGL [2.9.2, 3) https://github.com/LWJGL/lwjgl/issues/128
xorg.xrandr # needed for LWJGL [2.9.2, 3) https://github.com/LWJGL/lwjgl/issues/128 ] ++ additionalPrograms;
]
++ additionalPrograms;
in in
["--prefix PRISMLAUNCHER_JAVA_PATHS : ${lib.makeSearchPath "bin/java" jdks}"] [ "--prefix PRISMLAUNCHER_JAVA_PATHS : ${lib.makeSearchPath "bin/java" jdks}" ]
++ lib.optionals stdenv.isLinux [ ++ lib.optionals stdenv.isLinux [
"--set LD_LIBRARY_PATH ${addOpenGLRunpath.driverLink}/lib:${lib.makeLibraryPath runtimeLibs}" "--set LD_LIBRARY_PATH ${addOpenGLRunpath.driverLink}/lib:${lib.makeLibraryPath runtimeLibs}"
"--prefix PATH : ${lib.makeBinPath runtimePrograms}" "--prefix PATH : ${lib.makeBinPath runtimePrograms}"
]; ];
meta = { meta = {
inherit inherit (prismlauncher'.meta)
(prismlauncher'.meta) description
description longDescription
longDescription homepage
homepage changelog
changelog license
license maintainers
maintainers mainProgram
mainProgram platforms
platforms ;
; };
}; }
}