Skip to content

Commit d10c79d

Browse files
committed
feat: simplify flag
1 parent 5eda4ee commit d10c79d

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

programs/shfmt.nix

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,7 @@ in
1717
imports = [
1818
(mkFormatterModule {
1919
name = "shfmt";
20-
args = [
21-
"-s"
22-
"-w"
23-
];
20+
args = [ "-w" ];
2421
includes = [
2522
"*.sh"
2623
"*.bash"
@@ -42,12 +39,22 @@ in
4239
shfmt](https://github.com/patrickvane/shfmt#description).
4340
'';
4441
};
42+
43+
simplify = lib.mkOption {
44+
type = lib.types.bool;
45+
default = true;
46+
description = ''
47+
Enables the `-s` (`--simplify`) flag, which simplifies code where possible.
48+
'';
49+
};
4550
};
4651

4752
config = lib.mkIf cfg.enable {
48-
settings.formatter.shfmt.options = lib.optionals (!isNull cfg.indent_size) [
49-
"-i"
50-
(toString cfg.indent_size)
51-
];
53+
settings.formatter.shfmt.options =
54+
(lib.optionals (!isNull cfg.indent_size) [
55+
"-i"
56+
(toString cfg.indent_size)
57+
])
58+
++ (lib.optionals (cfg.simplify) [ "-s" ]);
5259
};
5360
}

0 commit comments

Comments
 (0)