nix-community / nixpkgs-fmt

Nix code formatter for nixpkgs [maintainer=@zimbatm]
https://nix-community.github.io/nixpkgs-fmt/
Apache License 2.0
582 stars 32 forks source link

Multi-line strings in let/in-expressions are wrongly indented #288

Open Ma27 opened 2 years ago

Ma27 commented 2 years ago

Input

{
  apps = let
    program = "${pkgs.writeScript "vim" ''
      #! /bin/sh
      exec ${package}/bin/foo
    ''}";
  in {
  };
}

Output

{
  apps =
    let
      program = "${pkgs.writeScript "vim" ''
      #! /bin/sh
      exec ${package}/bin/foo
    ''}";
    in
    { };
}

Desired output

{
  apps =
    let
      program = "${pkgs.writeScript "vim" ''
        #! /bin/sh
        exec ${package}/bin/foo
      ''}";
    in
    { };
}

Additional context

Tested on rev 79da650fa1a148fb759b40bf89d74a35284bceb8

Note: of course the snippet above doesn't make much sense, I tried to narrow it down to a more minimal example to demonstrate the issue. The code where I encountered the issue is available at https://gitlab.com/Ma27/nvim.nix/-/blob/b2b1a6d2889d8b2c5d7c60bb97586e26dc025935/flake.nix#L307-322