refactor(nix): cleanup flake

Signed-off-by: Seth Flynn <getchoo@tuta.io>
This commit is contained in:
Seth Flynn 2025-03-30 17:11:51 -04:00
parent c367f48ec9
commit 32b49ecb84
No known key found for this signature in database
GPG Key ID: D31BD0D494BBEE86
2 changed files with 58 additions and 55 deletions

View File

@ -22,8 +22,8 @@
self, self,
nixpkgs, nixpkgs,
libnbtplusplus, libnbtplusplus,
...
}: }:
let let
inherit (nixpkgs) lib; inherit (nixpkgs) lib;
@ -35,30 +35,71 @@
forAllSystems = lib.genAttrs systems; forAllSystems = lib.genAttrs systems;
nixpkgsFor = forAllSystems (system: nixpkgs.legacyPackages.${system}); nixpkgsFor = forAllSystems (system: nixpkgs.legacyPackages.${system});
in in
{ {
checks = forAllSystems ( checks = forAllSystems (
system: system:
let let
checks' = nixpkgsFor.${system}.callPackage ./nix/checks.nix { inherit self; }; pkgs = nixpkgsFor.${system};
llvm = pkgs.llvmPackages_19;
in in
lib.filterAttrs (_: lib.isDerivation) checks'
{
formatting =
pkgs.runCommand "check-formatting"
{
nativeBuildInputs = with pkgs; [
deadnix
llvm.clang-tools
markdownlint-cli
nixfmt-rfc-style
statix
];
}
''
cd ${self}
echo "Running clang-format...."
clang-format --dry-run --style='file' --Werror */**.{c,cc,cpp,h,hh,hpp}
echo "Running deadnix..."
deadnix --fail
echo "Running markdownlint..."
markdownlint --dot .
echo "Running nixfmt..."
find -type f -name '*.nix' -exec nixfmt --check {} +
echo "Running statix"
statix check .
touch $out
'';
}
); );
devShells = forAllSystems ( devShells = forAllSystems (
system: system:
let let
pkgs = nixpkgsFor.${system}; pkgs = nixpkgsFor.${system};
llvm = pkgs.llvmPackages_19;
packages' = self.packages.${system};
in in
{ {
default = pkgs.mkShell { default = pkgs.mkShell {
inputsFrom = [ self.packages.${system}.prismlauncher-unwrapped ]; inputsFrom = [ packages'.prismlauncher-unwrapped ];
buildInputs = with pkgs; [
nativeBuildInputs = with pkgs; [
ccache ccache
ninja llvm.clang-tools
llvmPackages_19.clang-tools
]; ];
cmakeFlags = self.packages.${system}.prismlauncher-unwrapped.cmakeFlags ++ [ cmakeFlags = packages'.prismlauncher-unwrapped.cmakeFlags ++ [
"-GNinja" "-GNinja"
"-Bbuild" "-Bbuild"
]; ];
@ -86,6 +127,7 @@
packages = forAllSystems ( packages = forAllSystems (
system: system:
let let
pkgs = nixpkgsFor.${system}; pkgs = nixpkgsFor.${system};
@ -98,6 +140,7 @@
default = prismPackages.prismlauncher; default = prismPackages.prismlauncher;
}; };
in in
# Only output them if they're available on the current system # Only output them if they're available on the current system
lib.filterAttrs (_: lib.meta.availableOn pkgs.stdenv.hostPlatform) packages lib.filterAttrs (_: lib.meta.availableOn pkgs.stdenv.hostPlatform) packages
); );
@ -105,16 +148,18 @@
# We put these under legacyPackages as they are meant for CI, not end user consumption # We put these under legacyPackages as they are meant for CI, not end user consumption
legacyPackages = forAllSystems ( legacyPackages = forAllSystems (
system: system:
let let
prismPackages = self.packages.${system}; packages' = self.packages.${system};
legacyPackages = self.legacyPackages.${system}; legacyPackages' = self.legacyPackages.${system};
in in
{ {
prismlauncher-debug = prismPackages.prismlauncher.override { prismlauncher-debug = packages'.prismlauncher.override {
prismlauncher-unwrapped = legacyPackages.prismlauncher-unwrapped-debug; prismlauncher-unwrapped = legacyPackages'.prismlauncher-unwrapped-debug;
}; };
prismlauncher-unwrapped-debug = prismPackages.prismlauncher-unwrapped.overrideAttrs { prismlauncher-unwrapped-debug = packages'.prismlauncher-unwrapped.overrideAttrs {
cmakeBuildType = "Debug"; cmakeBuildType = "Debug";
dontStrip = true; dontStrip = true;
}; };

View File

@ -1,42 +0,0 @@
{
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 --dry-run --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
'';
}