Skip to content

Allow indent_size to be unset for shfmt #97

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 1, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions programs/shfmt.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,24 @@ in
enable = lib.mkEnableOption "shfmt";
package = lib.mkPackageOption pkgs "shfmt" { };
indent_size = lib.mkOption {
type = lib.types.int;
type = lib.types.nullOr lib.types.int;
default = 2;
example = 4;
description = lib.mdDoc ''
Sets the number of spaces to be used in indentation. Uses tabs if set to zero.
Sets the number of spaces to be used in indentation. Uses tabs if set to
zero. If this is null, then [.editorconfig will be used to configure
shfmt](https://github.com/patrickvane/shfmt#description).
'';
};
};

config = lib.mkIf cfg.enable {
settings.formatter.shfmt = {
command = cfg.package;
options = [ "-i" (toString cfg.indent_size) "-s" "-w" ];
options =
(lib.optionals (!isNull cfg.indent_size)
[ "-i" (toString cfg.indent_size) ])
++ [ "-s" "-w" ];
includes = [ "*.sh" ];
};
};
Expand Down