Skip to content

Commit 8fc04de

Browse files
kalbasitrissson
authored andcommitted
integrate pre-commit as a hook with nix
1 parent 3c60872 commit 8fc04de

File tree

3 files changed

+97
-0
lines changed

3 files changed

+97
-0
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/.pre-commit-config.yaml
12
/flake.lock
23
/result*
34
/template/flake.lock

flake.lock

+77
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

+19
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@
1818
inputs.nixpkgs.follows = "nixpkgs";
1919
};
2020

21+
pre-commit-hooks = {
22+
inputs.nixpkgs.follows = "nixpkgs";
23+
url = "github:cachix/pre-commit-hooks.nix";
24+
};
25+
2126
sops-nix = {
2227
url = "github:Mic92/sops-nix";
2328
inputs = {
@@ -30,6 +35,7 @@
3035
outputs =
3136
{
3237
flake-utils-plus,
38+
pre-commit-hooks,
3339
nixpkgs,
3440
self,
3541
...
@@ -59,9 +65,22 @@
5965
system:
6066
let
6167
pkgs = nixpkgs.legacyPackages.${system};
68+
pre-commit-check = pre-commit-hooks.lib.${pkgs.hostPlatform.system}.run {
69+
src = ./.;
70+
hooks = {
71+
# TODO: Fix all errors and enable statix
72+
# statix.enable = true;
73+
nixfmt-rfc-style.enable = true;
74+
};
75+
};
6276
in
6377
{
78+
checks = {
79+
inherit pre-commit-check;
80+
};
81+
6482
devShell = pkgs.mkShell {
83+
inherit (pre-commit-check) shellHook;
6584
buildInputs = with pkgs; [
6685
git
6786
nixfmt-rfc-style

0 commit comments

Comments
 (0)