-
Notifications
You must be signed in to change notification settings - Fork 155
Expand file tree
/
Copy pathnixfmt.nix
More file actions
64 lines (59 loc) · 1.26 KB
/
nixfmt.nix
File metadata and controls
64 lines (59 loc) · 1.26 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
63
64
{
lib,
config,
mkFormatterModule,
...
}:
let
cfg = config.programs.nixfmt;
in
{
meta.maintainers = [
"NixOS/nixpkgs-ci"
];
imports = [
(mkFormatterModule {
name = "nixfmt";
package = "nixfmt";
includes = [ "*.nix" ];
})
];
options.programs.nixfmt = {
strict = lib.mkOption {
type = lib.types.bool;
default = false;
description = ''
Enable a stricter formatting mode that isn't influenced
as much by how the input is formatted.
'';
};
width = lib.mkOption {
type = lib.types.nullOr lib.types.int;
default = null;
example = 120;
description = ''
Maximum width in characters [default: 100]
'';
};
indent = lib.mkOption {
type = lib.types.nullOr lib.types.int;
default = null;
example = 4;
description = ''
Number of spaces to use for indentation [default: 2]
'';
};
};
config = lib.mkIf cfg.enable {
settings.formatter.nixfmt.options =
lib.optionals (!isNull cfg.width) [
"--width"
(toString cfg.width)
]
++ lib.optionals (!isNull cfg.indent) [
"--indent"
(toString cfg.indent)
]
++ lib.optional cfg.strict "--strict";
};
}