-
Notifications
You must be signed in to change notification settings - Fork 161
Expand file tree
/
Copy pathshellcheck.nix
More file actions
62 lines (59 loc) · 1.56 KB
/
shellcheck.nix
File metadata and controls
62 lines (59 loc) · 1.56 KB
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
{
config,
lib,
mkFormatterModule,
...
}:
let
cfg = config.programs.shellcheck;
in
{
meta.maintainers = [ "zimbatm" ];
meta.brokenPlatforms = [ "riscv64-linux" ];
options.programs.shellcheck = {
external-sources = lib.mkEnableOption "Allow sources outside of `includes`";
extra-checks = lib.mkOption {
description = ''
List of optional checks to enable (or "all")
'';
type = lib.types.listOf lib.types.str;
default = [ ];
example = [ "all" ];
};
severity = lib.mkOption {
description = ''
Minimum severity of errors to consider ("error", "warning", "info", "style")
'';
type = lib.types.nullOr lib.types.str;
default = null;
};
source-path = lib.mkOption {
description = ''
Specify path when looking for sourced files ("SCRIPTDIR" for script's dir)
'';
type = lib.types.nullOr lib.types.str;
default = null;
};
};
imports = [
(mkFormatterModule {
name = "shellcheck";
includes = [
"*.sh"
"*.bash"
# direnv
"*.envrc"
"*.envrc.*"
];
})
];
config = lib.mkIf cfg.enable {
settings.formatter.shellcheck.options =
(lib.optional cfg.external-sources "--external-sources")
++ (lib.optional (
cfg.extra-checks != [ ]
) "--enable=${lib.strings.concatStringsSep "," cfg.extra-checks}")
++ (lib.optional (cfg.severity != null) "--severity=${cfg.severity}")
++ (lib.optional (cfg.source-path != null) "--source-path=${cfg.source-path}");
};
}