refactor(nix): cleanup flake
Signed-off-by: Seth Flynn <getchoo@tuta.io> (cherry picked from commit 32b49ecb84da5683bce42e2e888319f4517f1d53)
This commit is contained in:
parent
80ff62c96d
commit
87c5b6cc83
78
flake.nix
78
flake.nix
@ -22,8 +22,8 @@
|
|||||||
self,
|
self,
|
||||||
nixpkgs,
|
nixpkgs,
|
||||||
libnbtplusplus,
|
libnbtplusplus,
|
||||||
...
|
|
||||||
}:
|
}:
|
||||||
|
|
||||||
let
|
let
|
||||||
inherit (nixpkgs) lib;
|
inherit (nixpkgs) lib;
|
||||||
|
|
||||||
@ -35,27 +35,79 @@
|
|||||||
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
|
||||||
];
|
];
|
||||||
|
|
||||||
|
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 (
|
packages = forAllSystems (
|
||||||
system:
|
system:
|
||||||
|
|
||||||
let
|
let
|
||||||
pkgs = nixpkgsFor.${system};
|
pkgs = nixpkgsFor.${system};
|
||||||
|
|
||||||
@ -87,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
|
||||||
);
|
);
|
||||||
@ -94,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;
|
||||||
};
|
};
|
||||||
|
@ -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
|
|
||||||
'';
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user