@@ -134,6 +134,59 @@ used at the same time.
134
134
135
135
- [ hunspell] ( https://github.com/hunspell/hunspell )
136
136
137
+ ## Custom hooks
138
+
139
+ Sometimes it is useful to add a project specific command as an extra check that
140
+ is not part of the pre-defined set of hooks provided by this project.
141
+
142
+ Example configuration:
143
+ ``` nix
144
+ let
145
+ nix-pre-commit-hooks = import (builtins.fetchTarball "https://github.com/cachix/pre-commit-hooks.nix/tarball/master");
146
+ in {
147
+ pre-commit-check = nix-pre-commit-hooks.run {
148
+ hooks = {
149
+ # ...
150
+
151
+ # Example custom hook for a C project using Make:
152
+ unit-tests = {
153
+ enable = true;
154
+
155
+ # The name of the hook (appears on the report table):
156
+ name = "Unit tests";
157
+
158
+ # The command to execute (mandatory):
159
+ entry = "make check";
160
+
161
+ # The pattern of files to run on (default: "" (all))
162
+ # see also https://pre-commit.com/#hooks-files
163
+ files = "\\.(c|h)$";
164
+
165
+ # List of file types to run on (default: [ "file" ] (all files))
166
+ # see also https://pre-commit.com/#filtering-files-with-types
167
+ # You probably only need to specify one of `files` or `types`:
168
+ types = [ "text" "c" ];
169
+
170
+ # Exclude files that were matched by these patterns (default: [ ] (none)):
171
+ excludes = [ "irrelevant\\.c" ];
172
+
173
+ # The language of the hook - tells pre-commit
174
+ # how to install the hook (default: "system")
175
+ # see also https://pre-commit.com/#supported-languages
176
+ language = "system";
177
+
178
+ # Set this to false to not pass the changed files
179
+ # to the command (default: true):
180
+ pass_filenames = false;
181
+ };
182
+ };
183
+ };
184
+ }
185
+ ```
186
+
187
+ Custom hooks are defined with the same schema as [ pre-defined
188
+ hooks] ( modules/pre-commit.nix ) .
189
+
137
190
# Contributing hooks
138
191
139
192
Everyone is encouraged to add new hooks.
0 commit comments