Skip to content

Commit 751dd45

Browse files
sellouto-az
authored andcommitted
Allow indent_size to be unset for shfmt (numtide#97)
* Allow indent_size to be unset for shfmt So the defaults don’t get in the way of reading the config file. * Revert the breaking change Also add some explanation and simplify a conditional.
1 parent c0f9add commit 751dd45

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

programs/shfmt.nix

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,24 @@ in
77
enable = lib.mkEnableOption "shfmt";
88
package = lib.mkPackageOption pkgs "shfmt" { };
99
indent_size = lib.mkOption {
10-
type = lib.types.int;
10+
type = lib.types.nullOr lib.types.int;
1111
default = 2;
1212
example = 4;
1313
description = lib.mdDoc ''
14-
Sets the number of spaces to be used in indentation. Uses tabs if set to zero.
14+
Sets the number of spaces to be used in indentation. Uses tabs if set to
15+
zero. If this is null, then [.editorconfig will be used to configure
16+
shfmt](https://github.com/patrickvane/shfmt#description).
1517
'';
1618
};
1719
};
1820

1921
config = lib.mkIf cfg.enable {
2022
settings.formatter.shfmt = {
2123
command = cfg.package;
22-
options = [ "-i" (toString cfg.indent_size) "-s" "-w" ];
24+
options =
25+
(lib.optionals (!isNull cfg.indent_size)
26+
[ "-i" (toString cfg.indent_size) ])
27+
++ [ "-s" "-w" ];
2328
includes = [ "*.sh" ];
2429
};
2530
};

0 commit comments

Comments
 (0)