-
Notifications
You must be signed in to change notification settings - Fork 92
/
Copy pathnixfmt.nix
49 lines (45 loc) · 954 Bytes
/
nixfmt.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
{
lib,
config,
mkFormatterModule,
...
}:
let
cfg = config.programs.nixfmt;
in
{
meta.maintainers = [ ];
imports = [
(mkFormatterModule {
name = "nixfmt";
package = "nixfmt-rfc-style";
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]
'';
};
};
config = lib.mkIf cfg.enable {
settings.formatter.nixfmt.options =
lib.optionals (!isNull cfg.width) [
"--width"
(toString cfg.width)
]
++ lib.optional cfg.strict "--strict";
};
}