Skip to content
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

shfmt breaks upon setting indent_size to null #313

Open
RossSmyth opened this issue Feb 11, 2025 · 2 comments
Open

shfmt breaks upon setting indent_size to null #313

RossSmyth opened this issue Feb 11, 2025 · 2 comments
Labels
bug Something isn't working

Comments

@RossSmyth
Copy link
Contributor

RossSmyth commented Feb 11, 2025

Describe the bug

To Reproduce

Steps to reproduce the behavior:

  1. Enable shfmt and set indent_size = null
error:
       … while calling the 'derivationStrict' builtin
         at <nix/derivation-internal.nix>:34:12:
           33|
           34|   strict = derivationStrict drvAttrs;
             |            ^
           35|

       … while evaluating derivation 'treefmt'
         whose name attribute is located at /nix/store/khbvilmsrv4l69nwd52h27j1mp44a0xi-source/pkgs/stdenv/generic/make-derivation.nix:375:7

       … while evaluating attribute 'text' of derivation 'treefmt'
         at /nix/store/khbvilmsrv4l69nwd52h27j1mp44a0xi-source/pkgs/build-support/trivial-builders/default.nix:102:17:
          101|       ({
          102|         inherit text executable checkPhase allowSubstitutes preferLocalBuild;
             |                 ^
          103|         passAsFile = [ "text" ]

       … while evaluating the option `build.configFile':

       (stack trace truncated; use '--show-trace' to show the full, detailed trace)

       error: A definition for option `settings.formatter.shfmt.indent_size' is not of type `TOML value'. Definition values:
       - In `<unknown-file>': null

Expected behavior

It does not provide a CLI argument and shfmt reads the .editorconfig file.

indent_size = lib.mkOption {
type = lib.types.nullOr lib.types.int;
default = 2;
example = 4;
description = ''
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).
'';
};

Versions
NixOS unstable
nixpkgs: a79cfe0ebd24952b580b1cf08cd906354996d547
treefmt: 4f09b47

Additional context

#96
@zimbatm
@katexochen

@RossSmyth RossSmyth added the bug Something isn't working label Feb 11, 2025
@zimbatm
Copy link
Member

zimbatm commented Feb 12, 2025

Try setting it on programs.shfmt.indent_size instead of formatter.shfmt.indent_size.

Programs is the higher-level abstraction.

@RossSmyth
Copy link
Contributor Author

Yeah that works, it's just not preferred imo as I am also applying an options flag.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants