forked from cachix/git-hooks.nix
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhooks.nix
108 lines (107 loc) · 2.86 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
{ 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 = [];
};
};
};
config.pre-commit.hooks =
{
ansible-lint =
{
name = "ansible-lint";
description =
"Ansible linter";
entry = "${tools.ansible-lint}/bin/ansible-lint";
};
hlint =
{
name = "hlint";
description =
"HLint gives suggestions on how to improve your source code.";
entry = "${tools.hlint}/bin/hlint";
files = "\\.l?hs$";
};
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$";
};
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";
};
};
}