Skip to content

Commit dc3c678

Browse files
committed
Use the module system, delegate activation to project.nix core
New - Selectively enable tools (#2) - Make choice of tool versions overridable - User-definable hooks - Input validation at the Nix level Fixes - Stop installing files all over the place when doing nix-shell ../some-project to borrow a tool - Lorri support Cleanup - Get rid of installation code
1 parent e3661fe commit dc3c678

File tree

6 files changed

+488
-116
lines changed

6 files changed

+488
-116
lines changed

.pre-commit-config.yaml

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,18 @@
1-
repos:
2-
- repo: .pre-commit-hooks/
3-
rev: master
4-
hooks:
5-
- id: shellcheck
6-
- id: canonix
1+
# DO NOT MODIFY
2+
# This file was generated by project.nix
3+
{
4+
"repos": [
5+
{
6+
"hooks": [
7+
{
8+
"id": "canonix"
9+
},
10+
{
11+
"id": "shellcheck"
12+
}
13+
],
14+
"repo": ".pre-commit-hooks/",
15+
"rev": "master"
16+
}
17+
]
18+
}

modules/hooks.nix

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
{ config, lib, pkgs, ... }:
2+
let
3+
inherit (config.pre-commit) tools;
4+
in {
5+
config.pre-commit.hooks =
6+
{
7+
hlint =
8+
{
9+
name = "hlint";
10+
description =
11+
"HLint gives suggestions on how to improve your source code.";
12+
entry = "${tools.hlint}/bin/hlint";
13+
files = "\\.l?hs$";
14+
};
15+
ormolu =
16+
{
17+
name = "ormolu";
18+
description = "Haskell code prettifier.";
19+
entry = "${tools.ormolu}/bin/ormolu --mode inplace";
20+
files = "\\.l?hs$";
21+
};
22+
hindent =
23+
{
24+
name = "hindent";
25+
description = "Haskell code prettifier.";
26+
entry = "${tools.hindent}/bin/hindent";
27+
files = "\\.l?hs$";
28+
};
29+
cabal-fmt =
30+
{
31+
name = "cabal-fmt";
32+
description = "Format Cabal files";
33+
entry = "${tools.cabal-fmt}/bin/cabal-fmt --inplace";
34+
files = "\\.cabal$";
35+
};
36+
canonix =
37+
{
38+
name = "canonix";
39+
description = "Nix code prettifier.";
40+
entry = "${tools.canonix}/bin/canonix";
41+
files = "\\.nix$";
42+
};
43+
nixfmt =
44+
{
45+
name = "nixfmt";
46+
description = "Nix code prettifier.";
47+
entry = "${tools.nixfmt}/bin/nixfmt";
48+
files = "\\.nix$";
49+
};
50+
nixpkgs-fmt =
51+
{
52+
name = "nixpkgs-fmt";
53+
description = "Nix code prettifier.";
54+
entry = "${tools.nixpkgs-fmt}/bin/nixpkgs-fmt -i";
55+
files = "\\.nix$";
56+
};
57+
elm-format =
58+
{
59+
name = "elm-format";
60+
description = "Format Elm files";
61+
entry =
62+
"${tools.elm-format}/bin/elm-format --yes --elm-version=0.19";
63+
files = "\\.elm$";
64+
};
65+
shellcheck =
66+
{
67+
name = "shellcheck";
68+
description = "Format shell files";
69+
types =
70+
[
71+
"bash"
72+
];
73+
entry = "${tools.shellcheck}/bin/shellcheck";
74+
};
75+
terraform-format =
76+
{
77+
name = "terraform-format";
78+
description = "Format terraform (.tf) files";
79+
entry = "${tools.terraform-fmt}/bin/terraform-fmt";
80+
files = "\\.tf$";
81+
};
82+
};
83+
}

0 commit comments

Comments
 (0)