treefmt-nix icon indicating copy to clipboard operation
treefmt-nix copied to clipboard

shfmt breaks upon setting indent_size to null

Open RossSmyth opened this issue 11 months ago • 2 comments

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. https://github.com/numtide/treefmt-nix/blob/4f09b473c936d41582dd744e19f34ec27592c5fd/programs/shfmt.nix#L34-L43

Versions NixOS unstable nixpkgs: a79cfe0ebd24952b580b1cf08cd906354996d547 treefmt: 4f09b473c936d41582dd744e19f34ec27592c5fd

Additional context

#96 @zimbatm @katexochen

RossSmyth avatar Feb 11 '25 21:02 RossSmyth

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

Programs is the higher-level abstraction.

zimbatm avatar Feb 12 '25 08:02 zimbatm

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

RossSmyth avatar Feb 12 '25 18:02 RossSmyth