nixfmt
nixfmt copied to clipboard
Function parameter attrset block formatting is not optimal to read
Description
Function parameter set blocks with default arguments are most clear and most pretty to read when the parameters are presented each on one line (and i tend to like it when they're sorted alphabetically, but i consider that optional).
nixfmt does generally produce really nice output and i would like to use it, but it seems suboptimal that it squashes such function parameter blocks to less readable format.
Small example input
foo = {
bar ? bla function call [] foobar {},
quux ? something very long,
baz ? []
}: builtins.toJSON {
# ...
}
Expected output
foo = {
bar ? bla function call [] foobar {},
, quux ? something very long,
, baz ? []
}:
builtins.toJSON {
# ...
}
Actual output
foo =
{ bar ? bla function call [] foobar {}, quux ? something very long, baz ? []}:
builtins.toJSON {
# ...
}
(please only look at the attrset parameter block, i don't care about the rest formatting, as nixfmt does that well)
This is especially bad when default parameters span multiple lines, like here:
{ haskellNix ? import (builtins.fetchTarball {
url =
"https://github.com/vitalbio/haskell.nix/archive/06435647a5a02a2bcf20ec156894e910721c8497.tar.gz"; # vital
sha256 = "190j32spzkf1cmwfsyyp996qkbfgj23blg2hwmi0xd9swj701c26";
}) { }, nixpkgsSrc ? haskellNix.sources.nixpkgs-2009 }:
_
It would be much nicer to indent the attrset passed to fetchTarball
to the level of haskellNix
The RFC format is completely different on this, and should not have this readability issue.