refactor: modularize checks into separate Nix files

- Extracted checks (clippy, doc, fmt, and toml-fmt) into modularized Nix files under `nix/checks`.
- Updated `flake.nix` to import checks from the new modularized structure.
- Improved clarity and maintainability by separating concerns for each check.
This commit is contained in:
Harald Hoyer 2025-03-24 11:47:20 +01:00
parent 28ad7cc65c
commit ce41414f4f
6 changed files with 92 additions and 33 deletions

13
nix/checks/clippy.nix Normal file
View file

@ -0,0 +1,13 @@
{
craneLib,
commonArgs,
cargoArtifacts,
}:
craneLib.cargoClippy (
commonArgs
// {
inherit cargoArtifacts;
cargoClippyExtraArgs = "--all-targets -- --deny warnings";
}
)

30
nix/checks/default.nix Normal file
View file

@ -0,0 +1,30 @@
{
craneLib,
src,
commonArgs,
cargoArtifacts,
vault-hier,
pkgs,
}:
{
inherit vault-hier;
my-workspace-clippy = import ./clippy.nix {
inherit craneLib commonArgs cargoArtifacts;
};
my-workspace-doc = import ./doc.nix {
inherit craneLib commonArgs cargoArtifacts;
};
# Check formatting
my-workspace-fmt = import ./fmt.nix {
inherit craneLib src;
};
my-workspace-toml-fmt = import ./toml-fmt.nix {
inherit craneLib src;
lib = pkgs.lib;
};
}

12
nix/checks/doc.nix Normal file
View file

@ -0,0 +1,12 @@
{
craneLib,
commonArgs,
cargoArtifacts,
}:
craneLib.cargoDoc (
commonArgs
// {
inherit cargoArtifacts;
}
)

5
nix/checks/fmt.nix Normal file
View file

@ -0,0 +1,5 @@
{ craneLib, src }:
craneLib.cargoFmt {
inherit src;
}

11
nix/checks/toml-fmt.nix Normal file
View file

@ -0,0 +1,11 @@
{
craneLib,
src,
lib,
}:
craneLib.taploFmt {
src = lib.sources.sourceFilesBySuffices src [ ".toml" ];
# taplo arguments can be further customized below as needed
# taploExtraArgs = "--config ./taplo.toml";
}