Skip to content

Commit f79a117

Browse files
committed
gersemi: init (#485)
1 parent 7592596 commit f79a117

2 files changed

Lines changed: 62 additions & 0 deletions

File tree

examples/formatter-gersemi.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Example generated by ../examples.sh
2+
[formatter.gersemi]
3+
command = "gersemi"
4+
excludes = []
5+
includes = ["CMakeLists.txt", "CMakeLists.txt.in", "*.cmake", "*.cmake.in"]
6+
options = ["-i"]

programs/gersemi.nix

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
{
2+
lib,
3+
config,
4+
mkFormatterModule,
5+
...
6+
}:
7+
let
8+
cfg = config.programs.gersemi;
9+
in
10+
{
11+
meta.maintainers = [ "vaisriv" ];
12+
13+
imports = [
14+
(mkFormatterModule {
15+
name = "gersemi";
16+
args = [ "-i" ];
17+
includes = [
18+
"CMakeLists.txt"
19+
"CMakeLists.txt.in"
20+
"*.cmake"
21+
"*.cmake.in"
22+
];
23+
})
24+
];
25+
26+
options.programs.gersemi = with lib; {
27+
indent = mkOption {
28+
type = types.nullOr (types.either (types.enum [ "tabs" ]) types.int);
29+
default = null;
30+
example = 2;
31+
description = ''
32+
Number of spaces used to indent or 'tabs' for indenting with tabs [default: 4]
33+
'';
34+
};
35+
lineLength = mkOption {
36+
type = types.nullOr types.int;
37+
default = null;
38+
example = 100;
39+
description = ''
40+
Maximum line length in characters. [default: 80]
41+
'';
42+
};
43+
};
44+
45+
config = lib.mkIf cfg.enable {
46+
settings.formatter.gersemi.options =
47+
(lib.optionals (!isNull cfg.indent) [
48+
"--indent"
49+
(toString cfg.indent)
50+
])
51+
++ (lib.optionals (!isNull cfg.lineLength) [
52+
"--line-length"
53+
(toString cfg.lineLength)
54+
]);
55+
};
56+
}

0 commit comments

Comments
 (0)