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
(
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

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)";
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

View file

@ -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
];
}
```

View file

@ -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;
};
}

View file

@ -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;
};
};
};
};
}

View file

@ -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;
};
}

View file

@ -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
;
};
}