-
Notifications
You must be signed in to change notification settings - Fork 89
/
Copy pathyamlfmt.nix
45 lines (41 loc) · 883 Bytes
/
yamlfmt.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
{
lib,
pkgs,
config,
mkFormatterModule,
...
}:
let
cfg = config.programs.yamlfmt;
settingsFormat = pkgs.formats.yaml { };
in
{
meta.maintainers = [ ];
imports = [
(mkFormatterModule {
name = "yamlfmt";
includes = [
"*.yaml"
"*.yml"
];
})
];
options.programs.yamlfmt = {
settings = lib.mkOption {
type = lib.types.submodule { freeformType = settingsFormat.type; };
default = { };
description = ''
Configuration for yamlfmt, see
<link xlink:href="https://github.com/google/yamlfmt/blob/main/docs/config-file.md"/>
for supported values.
'';
};
};
config = lib.mkIf cfg.enable {
settings.formatter.yamlfmt = {
options = lib.optional (
cfg.settings != { }
) "-conf=${settingsFormat.generate "yamlfmt.conf" cfg.settings}";
};
};
}