forked from cachix/git-hooks.nix
-
Notifications
You must be signed in to change notification settings - Fork 0
/
hooks.nix
3393 lines (3324 loc) · 124 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
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
{ config, lib, pkgs, hookModule, ... }:
let
inherit (config) hooks tools settings;
cfg = config;
inherit (lib) flatten mapAttrs mapAttrsToList mkDefault mkOption mkRemovedOptionModule mkRenamedOptionModule types;
cargoManifestPathArg =
lib.optionalString
(settings.rust.cargoManifestPath != null)
"--manifest-path ${lib.escapeShellArg settings.rust.cargoManifestPath}";
mkCmdArgs = predActionList:
lib.concatStringsSep
" "
(builtins.foldl'
(acc: entry:
acc ++ lib.optional (builtins.elemAt entry 0) (builtins.elemAt entry 1))
[ ]
predActionList);
migrateBinPathToPackage = hook: binPath:
if hook.settings.binPath == null
then "${hook.package}${binPath}"
else hook.settings.binPath;
in
{
imports =
# Rename `settings.<name>.package` to `hooks.<name>.package`
map (name: mkRenamedOptionModule [ "settings" name "package" ] [ "hooks" name "package" ]) [ "alejandra" "eclint" "flynt" "mdl" "treefmt" ]
# These options were renamed in 20fbe2c9731810b1020572a2cb6cbf64e3dd3873 to avoid shadowing
++ map (name: mkRenamedOptionModule [ "settings" name "config" ] [ "hooks" name "settings" "configuration" ]) [ "lua-ls" "markdownlint" "typos" "vale" ]
++ [
(mkRemovedOptionModule [ "settings" "yamllint" "relaxed" ] ''
This option has been removed. Use `hooks.yamllint.settings.preset = "relaxed"`.
'')
]
# Manually rename options that had a package or a config option
++ flatten (mapAttrsToList (name: map (o: mkRenamedOptionModule [ "settings" name o ] [ "hooks" name "settings" o ])) {
"alejandra" = [ "check" "exclude" "threads" "verbosity" ];
"eclint" = [ "fix" "summary" "color" "exclude" "verbosity" ];
"flynt" = [ "aggressive" "binPath" "dry-run" "exclude" "fail-on-change" "line-length" "no-multiline" "quiet" "string" "transform-concats" "verbose" ];
"mdl" = [ "configPath" "git-recurse" "ignore-front-matter" "json" "rules" "rulesets" "show-aliases" "warnings" "skip-default-ruleset" "style" "tags" "verbose" ];
"lua-ls" = [ "checklevel" ];
"typos" = [ "binary" "color" "configPath" "diff" "exclude" "format" "hidden" "ignored-words" "locale" "no-check-filenames" "no-check-files" "no-unicode" "quiet" "verbose" "write" ];
"vale" = [ "configPath" "flags" ];
"yamllint" = [ "configPath" ];
})
# Rename the remaining `settings.<name>` to `hooks.<name>.settings`
++ map (name: mkRenamedOptionModule [ "settings" name ] [ "hooks" name "settings" ])
[ "ansible-lint" "autoflake" "clippy" "cmake-format" "credo" "deadnix" "denofmt" "denolint" "dune-fmt" "eslint" "flake8" "headache" "hlint" "hpack" "isort" "latexindent" "lychee" "mkdocs-linkcheck" "mypy" "nixfmt" "ormolu" "php-cs-fixer" "phpcbf" "phpcs" "phpstan" "prettier" "psalm" "pylint" "pyright" "pyupgrade" "revive" "rome" "statix" ];
options.hookModule = lib.mkOption {
type = types.deferredModule;
internal = true;
description = ''
Base module that must be loaded into each hook.
'';
};
config.hookModule = {
imports = [ ./hook.nix ];
config._module.args.default_stages = cfg.default_stages;
};
config._module.args.hookModule = config.hookModule;
# PLEASE keep this sorted alphabetically.
options.settings = {
rust.cargoManifestPath = mkOption {
type = types.nullOr types.str;
description = lib.mdDoc "Path to Cargo.toml";
default = null;
};
};
# PLEASE keep this sorted alphabetically.
options.hooks =
{
alejandra = mkOption {
description = lib.mdDoc "alejandra hook";
type = types.submodule {
imports = [ hookModule ];
options.settings = {
check =
mkOption {
type = types.bool;
description = lib.mdDoc "Check if the input is already formatted and disable writing in-place the modified content";
default = false;
example = true;
};
exclude =
mkOption {
type = types.listOf types.str;
description = lib.mdDoc "Files or directories to exclude from formatting.";
default = [ ];
example = [ "flake.nix" "./templates" ];
};
threads =
mkOption {
type = types.nullOr types.int;
description = lib.mdDoc "Number of formatting threads to spawn.";
default = null;
example = 8;
};
verbosity =
mkOption {
type = types.enum [ "normal" "quiet" "silent" ];
description = lib.mdDoc "Whether informational messages or all messages should be hidden or not.";
default = "normal";
example = "quiet";
};
};
};
};
ansible-lint = mkOption {
description = lib.mdDoc "ansible-lint hook";
type = types.submodule {
imports = [ hookModule ];
options.settings = {
configPath = mkOption {
type = types.str;
description = lib.mdDoc "Path to the YAML configuration file.";
# an empty string translates to use default configuration of the
# underlying ansible-lint binary
default = "";
};
subdir = mkOption {
type = types.str;
description = lib.mdDoc "Path to the Ansible subdirectory.";
default = "";
};
};
};
};
autoflake = mkOption {
description = lib.mdDoc "autoflake hook";
type = types.submodule {
imports = [ hookModule ];
options.settings = {
binPath =
mkOption {
type = types.nullOr types.str;
description = lib.mdDoc "Path to autoflake binary.";
default = null;
defaultText = lib.literalExpression ''
"''${tools.autoflake}/bin/autoflake"
'';
};
flags =
mkOption {
type = types.str;
description = lib.mdDoc "Flags passed to autoflake.";
default = "--in-place --expand-star-imports --remove-duplicate-keys --remove-unused-variables";
};
};
};
};
black = mkOption {
description = lib.mdDoc "black hook";
type = types.submodule {
imports = [ hookModule ];
options.settings = {
flags = mkOption {
type = types.str;
description = lib.mdDoc "Flags passed to black. See all available [here](https://black.readthedocs.io/en/stable/usage_and_configuration/the_basics.html#command-line-options).";
default = "";
example = "--skip-magic-trailing-comma";
};
};
};
};
clippy = mkOption {
description = lib.mdDoc "clippy hook";
type = types.submodule {
imports = [ hookModule ];
options.packageOverrides = {
cargo = mkOption {
type = types.package;
description = lib.mdDoc "The cargo package to use";
};
clippy = mkOption {
type = types.package;
description = lib.mdDoc "The clippy package to use";
};
};
options.settings = {
denyWarnings = mkOption {
type = types.bool;
description = lib.mdDoc "Fail when warnings are present";
default = false;
};
offline = mkOption {
type = types.bool;
description = lib.mdDoc "Run clippy offline";
default = true;
};
allFeatures = mkOption {
type = types.bool;
description = lib.mdDoc "Run clippy with --all-features";
default = false;
};
};
};
};
cmake-format = mkOption {
description = lib.mdDoc "cmake-format hook";
type = types.submodule {
imports = [ hookModule ];
options.settings = {
configPath = mkOption {
type = types.str;
description = lib.mdDoc "Path to the configuration file (.json,.python,.yaml)";
default = "";
example = ".cmake-format.json";
};
};
};
};
credo = mkOption {
description = lib.mdDoc "credo hook";
type = types.submodule {
imports = [ hookModule ];
options.settings = {
strict =
mkOption {
type = types.bool;
description = lib.mdDoc "Whether to auto-promote the changes.";
default = true;
};
};
};
};
deadnix = mkOption {
description = lib.mdDoc "deadnix hook";
type = types.submodule {
imports = [ hookModule ];
options.settings = {
edit =
mkOption {
type = types.bool;
description = lib.mdDoc "Remove unused code and write to source file.";
default = false;
};
exclude =
mkOption {
type = types.listOf types.str;
description = lib.mdDoc "Files to exclude from analysis.";
default = [ ];
};
hidden =
mkOption {
type = types.bool;
description = lib.mdDoc "Recurse into hidden subdirectories and process hidden .*.nix files.";
default = false;
};
noLambdaArg =
mkOption {
type = types.bool;
description = lib.mdDoc "Don't check lambda parameter arguments.";
default = false;
};
noLambdaPatternNames =
mkOption {
type = types.bool;
description = lib.mdDoc "Don't check lambda pattern names (don't break nixpkgs `callPackage`).";
default = false;
};
noUnderscore =
mkOption {
type = types.bool;
description = lib.mdDoc "Don't check any bindings that start with a `_`.";
default = false;
};
quiet =
mkOption {
type = types.bool;
description = lib.mdDoc "Don't print a dead code report.";
default = false;
};
};
};
};
denofmt = mkOption {
description = lib.mdDoc "denofmt hook";
type = types.submodule {
imports = [ hookModule ];
options.settings = {
write =
mkOption {
type = types.bool;
description = lib.mdDoc "Whether to edit files inplace.";
default = true;
};
configPath =
mkOption {
type = types.str;
description = lib.mdDoc "Path to the configuration JSON file";
# an empty string translates to use default configuration of the
# underlying deno binary (i.e deno.json or deno.jsonc)
default = "";
};
};
};
};
denolint = mkOption {
description = lib.mdDoc "denolint hook";
type = types.submodule {
imports = [ hookModule ];
options.settings = {
format =
mkOption {
type = types.enum [ "default" "compact" "json" ];
description = lib.mdDoc "Output format.";
default = "default";
};
configPath =
mkOption {
type = types.str;
description = lib.mdDoc "Path to the configuration JSON file";
# an empty string translates to use default configuration of the
# underlying deno binary (i.e deno.json or deno.jsonc)
default = "";
};
};
};
};
dune-fmt = mkOption {
description = lib.mdDoc "dune-fmt hook";
type = types.submodule {
imports = [ hookModule ];
options.settings = {
auto-promote =
mkOption {
type = types.bool;
description = lib.mdDoc "Whether to auto-promote the changes.";
default = true;
};
extraRuntimeInputs =
mkOption {
type = types.listOf types.package;
description = lib.mdDoc "Extra runtimeInputs to add to the environment, eg. `ocamlformat`.";
default = [ ];
};
};
};
};
eclint = mkOption {
description = lib.mdDoc "eclint hook";
type = types.submodule {
imports = [ hookModule ];
options.settings = {
fix =
mkOption {
type = types.bool;
description = lib.mdDoc "Modify files in place rather than showing the errors.";
default = false;
};
summary =
mkOption {
type = types.bool;
description = lib.mdDoc "Only show number of errors per file.";
default = false;
};
color =
mkOption {
type = types.enum [ "auto" "always" "never" ];
description = lib.mdDoc "When to generate colored output.";
default = "auto";
};
exclude =
mkOption {
type = types.listOf types.str;
description = lib.mdDoc "Filter to exclude files.";
default = [ ];
};
verbosity =
mkOption {
type = types.enum [ 0 1 2 3 4 ];
description = lib.mdDoc "Log level verbosity";
default = 0;
};
};
};
};
eslint = mkOption {
description = lib.mdDoc "eslint hook";
type = types.submodule {
imports = [ hookModule ];
options.settings = {
binPath =
mkOption {
type = types.nullOr types.path;
description = lib.mdDoc
"`eslint` binary path. E.g. if you want to use the `eslint` in `node_modules`, use `./node_modules/.bin/eslint`.";
default = null;
defaultText = lib.literalExpression "\${tools.eslint}/bin/eslint";
};
extensions =
mkOption {
type = types.str;
description = lib.mdDoc
"The pattern of files to run on, see [https://pre-commit.com/#hooks-files](https://pre-commit.com/#hooks-files).";
default = "\\.js$";
};
};
};
};
flake8 = mkOption {
description = lib.mdDoc "flake8 hook";
type = types.submodule {
imports = [ hookModule ];
options.settings = {
binPath =
mkOption {
type = types.nullOr types.str;
description = lib.mdDoc "flake8 binary path. Should be used to specify flake8 binary from your Nix-managed Python environment.";
default = null;
defaultText = lib.literalExpression ''
"''${tools.flake8}/bin/flake8"
'';
};
extendIgnore =
mkOption {
type = types.listOf types.str;
description = lib.mdDoc "List of additional ignore codes";
default = [ ];
example = [ "E501" ];
};
format =
mkOption {
type = types.str;
description = lib.mdDoc "Output format.";
default = "default";
};
};
};
};
flynt = mkOption {
description = lib.mdDoc "flynt hook";
type = types.submodule {
imports = [ hookModule ];
options.settings = {
aggressive =
mkOption {
type = types.bool;
description = lib.mdDoc "Include conversions with potentially changed behavior.";
default = false;
};
binPath =
mkOption {
type = types.nullOr types.str;
description = lib.mdDoc "flynt binary path. Can be used to specify the flynt binary from an existing Python environment.";
default = null;
defaultText = "\${hooks.flynt.package}/bin/flynt";
};
dry-run =
mkOption {
type = types.bool;
description = lib.mdDoc "Do not change files in-place and print diff instead.";
default = false;
};
exclude =
mkOption {
type = types.listOf types.str;
description = lib.mdDoc "Ignore files with given strings in their absolute path.";
default = [ ];
};
fail-on-change =
mkOption {
type = types.bool;
description = lib.mdDoc "Fail when diff is not empty (for linting purposes).";
default = true;
};
line-length =
mkOption {
type = types.nullOr types.int;
description = lib.mdDoc "Convert expressions spanning multiple lines, only if the resulting single line will fit into this line length limit.";
default = null;
};
no-multiline =
mkOption {
type = types.bool;
description = lib.mdDoc "Convert only single line expressions.";
default = false;
};
quiet =
mkOption {
type = types.bool;
description = lib.mdDoc "Run without output.";
default = false;
};
string =
mkOption {
type = types.bool;
description = lib.mdDoc "Interpret the input as a Python code snippet and print the converted version.";
default = false;
};
transform-concats =
mkOption {
type = types.bool;
description = lib.mdDoc "Replace string concatenations with f-strings.";
default = false;
};
verbose =
mkOption {
type = types.bool;
description = lib.mdDoc "Run with verbose output.";
default = false;
};
};
};
};
headache = mkOption {
description = lib.mdDoc "headache hook";
type = types.submodule {
imports = [ hookModule ];
options.settings = {
header-file = mkOption {
type = types.str;
description = lib.mdDoc "Path to the header file.";
default = ".header";
};
};
};
};
hlint = mkOption {
description = lib.mdDoc "hlint hook";
type = types.submodule {
imports = [ hookModule ];
options.settings = {
hintFile =
mkOption {
type = types.nullOr types.path;
description = lib.mdDoc "Path to hlint.yaml. By default, hlint searches for .hlint.yaml in the project root.";
default = null;
};
};
};
};
hpack = mkOption {
description = lib.mdDoc "hpack hook";
type = types.submodule {
imports = [ hookModule ];
options.settings = {
silent =
mkOption {
type = types.bool;
description = lib.mdDoc "Whether generation should be silent.";
default = false;
};
};
};
};
isort = mkOption {
description = lib.mdDoc "isort hook";
type = types.submodule {
imports = [ hookModule ];
options.settings = {
profile =
mkOption {
type = types.enum [ "" "black" "django" "pycharm" "google" "open_stack" "plone" "attrs" "hug" "wemake" "appnexus" ];
description = lib.mdDoc "Built-in profiles to allow easy interoperability with common projects and code styles.";
default = "";
};
flags =
mkOption {
type = types.str;
description = lib.mdDoc "Flags passed to isort. See all available [here](https://pycqa.github.io/isort/docs/configuration/options.html).";
default = "";
};
};
};
};
latexindent = mkOption {
description = lib.mdDoc "latexindent hook";
type = types.submodule {
imports = [ hookModule ];
options.settings = {
flags =
mkOption {
type = types.str;
description = lib.mdDoc "Flags passed to latexindent. See available flags [here](https://latexindentpl.readthedocs.io/en/latest/sec-how-to-use.html#from-the-command-line)";
default = "--local --silent --overwriteIfDifferent";
};
};
};
};
lua-ls = mkOption {
description = lib.mdDoc "lua-ls hook";
type = types.submodule {
imports = [ hookModule ];
options.settings = {
checklevel = mkOption {
type = types.enum [ "Error" "Warning" "Information" "Hint" ];
description = lib.mdDoc
"The diagnostic check level";
default = "Warning";
};
configuration = mkOption {
type = types.attrs;
description = lib.mdDoc
"See https://github.com/LuaLS/lua-language-server/wiki/Configuration-File#luarcjson";
default = { };
};
};
};
};
lychee = mkOption {
description = lib.mdDoc "lychee hook";
type = types.submodule {
imports = [ hookModule ];
options.settings = {
configPath =
mkOption {
type = types.str;
description = lib.mdDoc "Path to the config file.";
default = "";
};
flags =
mkOption {
type = types.str;
description = lib.mdDoc "Flags passed to lychee. See all available [here](https://lychee.cli.rs/#/usage/cli).";
default = "";
};
};
};
};
markdownlint = mkOption {
description = lib.mdDoc "markdownlint hook";
type = types.submodule {
imports = [ hookModule ];
options.settings = {
configuration =
mkOption {
type = types.attrs;
description = lib.mdDoc
"See https://github.com/DavidAnson/markdownlint/blob/main/schema/.markdownlint.jsonc";
default = { };
};
};
};
};
mdl = mkOption {
description = lib.mdDoc "mdl hook";
type = types.submodule {
imports = [ hookModule ];
options.settings = {
configPath =
mkOption {
type = types.str;
description = lib.mdDoc "The configuration file to use.";
default = "";
};
git-recurse =
mkOption {
type = types.bool;
description = lib.mdDoc "Only process files known to git when given a directory.";
default = false;
};
ignore-front-matter =
mkOption {
type = types.bool;
description = lib.mdDoc "Ignore YAML front matter.";
default = false;
};
json =
mkOption {
type = types.bool;
description = lib.mdDoc "Format output as JSON.";
default = false;
};
rules =
mkOption {
type = types.listOf types.str;
description = lib.mdDoc "Markdown rules to use for linting. Per default all rules are processed.";
default = [ ];
};
rulesets =
mkOption {
type = types.listOf types.str;
description = lib.mdDoc "Specify additional ruleset files to load.";
default = [ ];
};
show-aliases =
mkOption {
type = types.bool;
description = lib.mdDoc "Show rule alias instead of rule ID when viewing rules.";
default = false;
};
warnings =
mkOption {
type = types.bool;
description = lib.mdDoc "Show Kramdown warnings.";
default = false;
};
skip-default-ruleset =
mkOption {
type = types.bool;
description = lib.mdDoc "Do not load the default markdownlint ruleset. Use this option if you only want to load custom rulesets.";
default = false;
};
style =
mkOption {
type = types.str;
description = lib.mdDoc "Select which style mdl uses.";
default = "default";
};
tags =
mkOption {
type = types.listOf types.str;
description = lib.mdDoc "Markdown rules to use for linting containing the given tags. Per default all rules are processed.";
default = [ ];
};
verbose =
mkOption {
type = types.bool;
description = lib.mdDoc "Increase verbosity.";
default = false;
};
};
};
};
mkdocs-linkcheck = mkOption {
description = lib.mdDoc "mkdocs-linkcheck hook";
type = types.submodule {
imports = [ hookModule ];
options.settings = {
binPath =
mkOption {
type = types.nullOr types.path;
description = lib.mdDoc "mkdocs-linkcheck binary path. Should be used to specify the mkdocs-linkcheck binary from your Nix-managed Python environment.";
default = null;
defaultText = lib.literalExpression ''
"''${tools.mkdocs-linkcheck}/bin/mkdocs-linkcheck"
'';
};
path =
mkOption {
type = types.str;
description = lib.mdDoc "Path to check";
default = "";
};
local-only =
mkOption {
type = types.bool;
description = lib.mdDoc "Whether to only check local links.";
default = false;
};
recurse =
mkOption {
type = types.bool;
description = lib.mdDoc "Whether to recurse directories under path.";
default = false;
};
extension =
mkOption {
type = types.str;
description = lib.mdDoc "File extension to scan for.";
default = "";
};
method =
mkOption {
type = types.enum [ "get" "head" ];
description = lib.mdDoc "HTTP method to use when checking external links.";
default = "get";
};
};
};
};
mypy = mkOption {
description = lib.mdDoc "mypy hook";
type = types.submodule {
imports = [ hookModule ];
options.settings = {
binPath =
mkOption {
type = types.nullOr types.str;
description = lib.mdDoc "Mypy binary path. Should be used to specify the mypy executable in an environment containing your typing stubs.";
default = null;
defaultText = lib.literalExpression ''
"''${tools.mypy}/bin/mypy"
'';
};
};
};
};
nixfmt = mkOption {
description = lib.mdDoc "nixfmt hook";
type = types.submodule {
imports = [ hookModule ];
options.settings = {
width =
mkOption {
type = types.nullOr types.int;
description = lib.mdDoc "Line width.";
default = null;
};
};
};
};
no-commit-to-branch = mkOption {
description = lib.mdDoc "no-commit-to-branch-hook";
type = types.submodule {
imports = [ hookModule ];
options.settings = {
branch =
mkOption {
description = lib.mdDoc "Branches to disallow commits to.";
type = types.listOf types.str;
default = [ "main" ];
example = [ "main" "master" ];
};
pattern =
mkOption {
description = lib.mdDoc "RegEx patterns for branch names to disallow commits to.";
type = types.listOf types.str;
default = [ ];
example = [ "ma.*" ];
};
};
};
};
ormolu = mkOption {
description = lib.mdDoc "ormolu hook";
type = types.submodule {
imports = [ hookModule ];
options.settings = {
defaultExtensions =
mkOption {
type = types.listOf types.str;
description = lib.mdDoc "Haskell language extensions to enable.";
default = [ ];
};
cabalDefaultExtensions =
mkOption {
type = types.bool;
description = lib.mdDoc "Use `default-extensions` from `.cabal` files.";
default = false;
};
};
};
};
php-cs-fixer = mkOption {
description = lib.mdDoc "php-cs-fixer hook";
type = types.submodule {
imports = [ hookModule ];
options.settings = {
binPath =
mkOption {
type = types.nullOr types.str;
description = lib.mdDoc "PHP-CS-Fixer binary path.";
default = null;
defaultText = lib.literalExpression ''
"''${tools.php-cs-fixer}/bin/php-cs-fixer"
'';
};
};
};
};
phpcbf = mkOption {
description = lib.mdDoc "phpcbf hook";
type = types.submodule {
imports = [ hookModule ];
options.settings = {
binPath =
mkOption {
type = types.nullOr types.str;
description = lib.mdDoc "PHP_CodeSniffer binary path.";
default = null;
defaultText = lib.literalExpression ''
"''${tools.phpcbf}/bin/phpcbf"
'';
};
};
};
};
phpcs = mkOption {
description = lib.mdDoc "phpcs hook";
type = types.submodule {
imports = [ hookModule ];
options.settings = {
binPath =
mkOption {
type = types.nullOr types.str;
description = lib.mdDoc "PHP_CodeSniffer binary path.";
default = null;
defaultText = lib.literalExpression ''
"''${tools.phpcs}/bin/phpcs"
'';
};
};
};
};
phpstan = mkOption {
description = lib.mdDoc "phpstan hook";
type = types.submodule {
imports = [ hookModule ];
options.settings = {
binPath =
mkOption {
type = types.nullOr types.str;
description = lib.mdDoc "PHPStan binary path.";
default = null;
defaultText = lib.literalExpression ''
"''${tools.phpstan}/bin/phpstan"
'';
};
};
};
};
# See all CLI flags for prettier [here](https://prettier.io/docs/en/cli.html).
# See all options for prettier [here](https://prettier.io/docs/en/options.html).
prettier = mkOption {
description = lib.mdDoc "prettier hook";
type = types.submodule {
imports = [ hookModule ];
options.settings = {
binPath =
mkOption {
description = lib.mdDoc
"`prettier` binary path. E.g. if you want to use the `prettier` in `node_modules`, use `./node_modules/.bin/prettier`.";
type = types.nullOr types.path;
default = null;
defaultText = lib.literalExpression ''
"''${tools.prettier}/bin/prettier"
'';
};
allow-parens =
mkOption {
description = lib.mdDoc "Include parentheses around a sole arrow function parameter.";
default = "always";
type = types.enum [ "always" "avoid" ];
};
bracket-same-line =
mkOption {
description = lib.mdDoc "Put > of opening tags on the last line instead of on a new line.";
type = types.bool;
default = false;
};
cache =
mkOption {
description = lib.mdDoc "Only format changed files.";
type = types.bool;
default = false;
};
cache-location =
mkOption {
description = lib.mdDoc "Path to the cache file location used by `--cache` flag.";
type = types.str;
default = "./node_modules/.cache/prettier/.prettier-cache";
};
cache-strategy =
mkOption {
description = lib.mdDoc "Strategy for the cache to use for detecting changed files.";
type = types.nullOr (types.enum [ "metadata" "content" ]);
default = null;
};
check =
mkOption {
description = lib.mdDoc "Output a human-friendly message and a list of unformatted files, if any.";
type = types.bool;
default = false;
};
list-different =
mkOption {
description = lib.mdDoc "Print the filenames of files that are different from Prettier formatting.";
type = types.bool;
default = true;
};
color =
mkOption {
description = lib.mdDoc "Colorize error messages.";
type = types.bool;
default = true;
};
configPath =
mkOption {
description = lib.mdDoc "Path to a Prettier configuration file (.prettierrc, package.json, prettier.config.js).";
type = types.str;
default = "";
};
config-precedence =
mkOption {
description = lib.mdDoc "Defines how config file should be evaluated in combination of CLI options.";
type = types.enum [ "cli-override" "file-override" "prefer-file" ];
default = "cli-override";