build(flake): add pre-commit-hook
Signed-off-by: Christina Sørensen <christina@cafkafk.com>
This commit is contained in:
parent
50bd636a64
commit
c5c988d465
2 changed files with 31 additions and 3 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -4,3 +4,4 @@
|
|||
/result
|
||||
|
||||
.direnv
|
||||
.pre-commit-config.yaml
|
||||
|
|
33
flake.nix
33
flake.nix
|
@ -130,15 +130,42 @@
|
|||
|
||||
# For `nix develop`:
|
||||
devShells.default = pkgs.mkShell {
|
||||
nativeBuildInputs = with pkgs; [rustup toolchain just convco];
|
||||
inherit (self.checks.${system}.pre-commit-check) shellHook;
|
||||
nativeBuildInputs = with pkgs; [
|
||||
rustup
|
||||
toolchain
|
||||
just
|
||||
convco
|
||||
powertest.packages.${pkgs.system}.default
|
||||
];
|
||||
};
|
||||
|
||||
# For `nix flake check`
|
||||
checks = {
|
||||
pre-commit-check = let
|
||||
# some treefmt formatters are not supported in pre-commit-hooks we filter them out for now.
|
||||
toFilter =
|
||||
# This is a nice hack to not have to manually filter we should keep in mind for a future refactor.
|
||||
# (builtins.attrNames pre-commit-hooks.packages.${system})
|
||||
["yamlfmt"];
|
||||
filterFn = n: _v: (!builtins.elem n toFilter);
|
||||
treefmtFormatters = pkgs.lib.mapAttrs (_n: v: {inherit (v) enable;}) (pkgs.lib.filterAttrs filterFn (import ./treefmt.nix).programs);
|
||||
in
|
||||
pre-commit-hooks.lib.${system}.run {
|
||||
src = ./.;
|
||||
hooks =
|
||||
treefmtFormatters
|
||||
// {
|
||||
convco.enable = true; # not in treefmt
|
||||
};
|
||||
};
|
||||
formatting = treefmtEval.config.build.check self;
|
||||
build = packages.check;
|
||||
default = packages.default;
|
||||
test = packages.test;
|
||||
inherit
|
||||
(packages)
|
||||
default
|
||||
test
|
||||
;
|
||||
lint = packages.clippy;
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue