feat: add clippy and cargo test as dev pre-commit hooks

Splits git hooks into two configurations: a sandbox-safe set for
`nix flake check` (rustfmt + commitizen) and a full dev set installed
via `nix develop` that also runs clippy (deny warnings) and cargo test.
This commit is contained in:
Konstantin Fickel 2026-04-19 21:15:51 +02:00
parent 8e69a6afe8
commit ec978590c0
Signed by: kfickel
GPG key ID: A793722F9933C1A5

View file

@ -141,6 +141,36 @@
};
};
mkGitHooksDev =
system:
let
pkgs = mkPkgs system;
toolchain = pkgs.rust-bin.stable.latest.default;
in
git-hooks.lib.${system}.run {
src = ./.;
hooks = {
rustfmt = {
enable = true;
package = toolchain;
};
clippy = {
enable = true;
package = toolchain;
settings.denyWarnings = true;
};
cargo-test = {
enable = true;
name = "cargo test";
entry = "${toolchain}/bin/cargo test";
pass_filenames = false;
language = "system";
files = "\\.(rs|toml)$";
};
commitizen.enable = true;
};
};
mkMuslCraneLib =
system:
let
@ -199,6 +229,21 @@
in
craneLib.buildPackage (commonArgs // { inherit cargoArtifacts; });
mkZedExtensionZip =
system:
let
pkgs = mkPkgs system;
zed-extension = mkZedExtension system;
in
pkgs.runCommand "streamd-zed-extension-${version}.zip" {
nativeBuildInputs = [ pkgs.zip ];
} ''
mkdir -p streamd-zed-extension
cp ${zed-extension}/extension.toml streamd-zed-extension/
cp ${zed-extension}/extension.wasm streamd-zed-extension/
zip -r $out streamd-zed-extension
'';
mkStreamdDeb =
system:
let
@ -250,9 +295,10 @@
streamd-deb = mkStreamdDeb system;
streamd-windows = mkStreamdWindows system;
zed-extension = mkZedExtension system;
zed-extension-zip = mkZedExtensionZip system;
in
{
inherit streamd streamd-musl streamd-deb streamd-windows zed-extension;
inherit streamd streamd-musl streamd-deb streamd-windows zed-extension zed-extension-zip;
default = streamd;
}
);
@ -339,7 +385,7 @@
];
shellHook = ''
${(mkGitHooksCheck system).shellHook}
${(mkGitHooksDev system).shellHook}
'';
};
}