refactor(nix): cleanup flake

Signed-off-by: Seth Flynn <getchoo@tuta.io>
(cherry picked from commit 32b49ecb84da5683bce42e2e888319f4517f1d53)
This commit is contained in:
Seth Flynn 2025-03-30 17:11:51 -04:00
parent 80ff62c96d
commit 87c5b6cc83
No known key found for this signature in database
GPG Key ID: D31BD0D494BBEE86
2 changed files with 67 additions and 53 deletions

View File

@ -22,8 +22,8 @@
self,
nixpkgs,
libnbtplusplus,
...
}:
let
inherit (nixpkgs) lib;
@ -35,27 +35,79 @@
forAllSystems = lib.genAttrs systems;
nixpkgsFor = forAllSystems (system: nixpkgs.legacyPackages.${system});
in
{
checks = forAllSystems (
system:
let
checks' = nixpkgsFor.${system}.callPackage ./nix/checks.nix { inherit self; };
pkgs = nixpkgsFor.${system};
llvm = pkgs.llvmPackages_19;
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 (
system:
let
pkgs = nixpkgsFor.${system};
llvm = pkgs.llvmPackages_19;
packages' = self.packages.${system};
in
{
default = pkgs.mkShell {
inputsFrom = [ self.packages.${system}.prismlauncher-unwrapped ];
buildInputs = with pkgs; [
inputsFrom = [ packages'.prismlauncher-unwrapped ];
nativeBuildInputs = with pkgs; [
ccache
ninja
llvm.clang-tools
];
cmakeFlags = packages'.prismlauncher-unwrapped.cmakeFlags ++ [
"-GNinja"
"-Bbuild"
];
shellHook = ''
cmake $cmakeFlags -D CMAKE_BUILD_TYPE=Debug
ln -s {build/,}compile_commands.json
'';
};
}
);
@ -75,6 +127,7 @@
packages = forAllSystems (
system:
let
pkgs = nixpkgsFor.${system};
@ -87,6 +140,7 @@
default = prismPackages.prismlauncher;
};
in
# Only output them if they're available on the current system
lib.filterAttrs (_: lib.meta.availableOn pkgs.stdenv.hostPlatform) packages
);
@ -94,16 +148,18 @@
# We put these under legacyPackages as they are meant for CI, not end user consumption
legacyPackages = forAllSystems (
system:
let
prismPackages = self.packages.${system};
legacyPackages = self.legacyPackages.${system};
packages' = self.packages.${system};
legacyPackages' = self.legacyPackages.${system};
in
{
prismlauncher-debug = prismPackages.prismlauncher.override {
prismlauncher-unwrapped = legacyPackages.prismlauncher-unwrapped-debug;
prismlauncher-debug = packages'.prismlauncher.override {
prismlauncher-unwrapped = legacyPackages'.prismlauncher-unwrapped-debug;
};
prismlauncher-unwrapped-debug = prismPackages.prismlauncher-unwrapped.overrideAttrs {
prismlauncher-unwrapped-debug = packages'.prismlauncher-unwrapped.overrideAttrs {
cmakeBuildType = "Debug";
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
'';
}