forked from cachix/git-hooks.nix
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhooks.nix
175 lines (174 loc) · 4.99 KB
/
hooks.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
{ config, lib, pkgs, ... }:
let
inherit (config.pre-commit) tools settings;
inherit (lib) mkOption types;
in
{
options.pre-commit.settings =
{
ormolu =
{
defaultExtensions =
mkOption {
type = types.listOf types.str;
description = "Haskell language extensions to enable";
default = [];
};
};
nix-linter =
{
checks =
mkOption {
type = types.listOf types.str;
description =
"Available checks (See `nix-linter --help-for [CHECK]` for more details)";
default = [];
};
};
};
config.pre-commit.hooks =
{
ansible-lint =
{
name = "ansible-lint";
description =
"Ansible linter";
entry = "${tools.ansible-lint}/bin/ansible-lint";
};
black =
{
name = "black";
description = "The uncompromising Python code formatter";
entry = "${pkgs.python3Packages.black}/bin/black";
types = [ "file" "python" ];
};
brittany =
{
name = "brittany";
description = "Haskell source code formatter.";
entry = "${tools.brittany}/bin/brittany --write-mode=inplace";
files = "\\.l?hs$";
};
hlint =
{
name = "hlint";
description =
"HLint gives suggestions on how to improve your source code.";
entry = "${tools.hlint}/bin/hlint";
files = "\\.l?hs$";
};
hpack =
{
name = "hpack";
description =
"hpack converts package definitions in the hpack format (package.yaml) to Cabal files.";
entry = "${tools.hpack}/bin/hpack --force .";
files = "(\\.l?hs$)|(^[^/]+\\.cabal$)|(^package\\.yaml$)";
pass_filenames = false;
};
ormolu =
{
name = "ormolu";
description = "Haskell code prettifier.";
entry =
"${tools.ormolu}/bin/ormolu --mode inplace ${
lib.escapeShellArgs (lib.concatMap (ext: [ "--ghc-opt" "-X${ext}" ]) settings.ormolu.defaultExtensions)
}";
files = "\\.l?hs$";
};
hindent =
{
name = "hindent";
description = "Haskell code prettifier.";
entry = "${tools.hindent}/bin/hindent";
files = "\\.l?hs$";
};
cabal-fmt =
{
name = "cabal-fmt";
description = "Format Cabal files";
entry = "${tools.cabal-fmt}/bin/cabal-fmt --inplace";
files = "\\.cabal$";
};
nixfmt =
{
name = "nixfmt";
description = "Nix code prettifier.";
entry = "${tools.nixfmt}/bin/nixfmt";
files = "\\.nix$";
};
nixpkgs-fmt =
{
name = "nixpkgs-fmt";
description = "Nix code prettifier.";
entry = "${tools.nixpkgs-fmt}/bin/nixpkgs-fmt";
files = "\\.nix$";
};
nix-linter =
{
name = "nix-linter";
description = "Linter for the Nix expression language.";
entry =
"${tools.nix-linter}/bin/nix-linter ${
lib.escapeShellArgs (lib.concatMap (check: [ "-W" "${check}" ]) settings.nix-linter.checks)
}";
files = "\\.nix$";
};
elm-format =
{
name = "elm-format";
description = "Format Elm files";
entry =
"${tools.elm-format}/bin/elm-format --yes --elm-version=0.19";
files = "\\.elm$";
};
shellcheck =
{
name = "shellcheck";
description = "Format shell files";
types =
[
"bash"
];
entry = "${tools.shellcheck}/bin/shellcheck";
};
terraform-format =
{
name = "terraform-format";
description = "Format terraform (.tf) files";
entry = "${tools.terraform-fmt}/bin/terraform-fmt";
files = "\\.tf$";
};
yamllint =
{
name = "yamllint";
description = "Yaml linter";
types = [ "file" "yaml" ];
entry = "${tools.yamllint}/bin/yamllint";
};
rustfmt =
{
name = "rustfmt";
description = "Format Rust code.";
entry = "${tools.rustfmt}/bin/cargo-fmt fmt -- --check --color always";
files = "\\.rs$";
pass_filenames = false;
};
clippy =
{
name = "clippy";
description = "Lint Rust code.";
entry = "${tools.clippy}/bin/cargo-clippy clippy";
files = "\\.rs$";
pass_filenames = false;
};
cargo-check =
{
name = "cargo-check";
description = "Check the cargo package for errors";
entry = "${tools.cargo}/bin/cargo check";
files = "\\.rs$";
pass_filenames = false;
};
};
}