chore(nix): add pre-commit checks

This commit is contained in:
Ananth Venkatesh 2025-02-01 03:42:40 -05:00
parent 0f4436787c
commit be8e419f66
Signed by: ananthv
GPG key ID: 4BB578E748CFE4FF
3 changed files with 99 additions and 7 deletions

View file

@ -5,6 +5,7 @@
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
utils.url = "github:numtide/flake-utils";
mkElmDerivation.url = "github:jeslie0/mkElmDerivation";
pre-commit-hooks.url = "github:cachix/pre-commit-hooks.nix";
};
outputs =
@ -13,6 +14,7 @@
nixpkgs,
utils,
mkElmDerivation,
pre-commit-hooks,
}:
utils.lib.eachDefaultSystem (
system:
@ -26,10 +28,13 @@
devShells.default =
with pkgs;
mkShell {
buildInputs = [
inherit (self.checks.${system}.pre-commit-check) shellHook;
buildInputs = self.checks.${system}.pre-commit-check.enabledPackages ++ [
elmPackages.elm
elmPackages.elm-test
elmPackages.elm-format
elmPackages.elm-review
entr
];
};
@ -50,6 +55,18 @@
};
};
checks = {
pre-commit-check = pre-commit-hooks.lib.${system}.run {
src = ./.;
hooks = {
nixfmt-rfc-style.enable = true;
elm-format.enable = true;
# elm-review.enable = true;
# elm-test.enable = true;
};
};
};
formatter = nixpkgs.legacyPackages.${system}.nixfmt-rfc-style;
}
);