I don’t really care about how code is indented that much, except for one instance. When brackets are unnecessarily placed on the same line as the items:
So I am writing here to try to convince you that anything else is better than that
This is fine:
fileSystems."/nix" = {
On it’s own line, it’s fine:
fileSystems."/nix" =
{
Ok but why? you will ask.
It takes more operations to sort lines
It takes more operations when touching the first item of the attribute set
Git diffs are unnecessarily larger
It’s not necessary
This also goes for arrays. Nix is one of the very few languages where we don’t have to worry about commas between array entries. In any other language you have to choose between an ugly diff in front, or in the back of the array. But we don’t!
Anyways, that’s about it. I understand that everyone has preferences and we have different language backgrounds. Some of these formats were influenced by the original language’s syntax restrictions and don’t have to apply in Nix.
Saving one line is the only motivation I can think of, i.e. not really convincing case. I agree with you, though I don’t mind that style so much; I’m not sure it’s worth to decide to convert all nixpkgs now but perhaps per-file (or a larger section of it) when that file/section is significantly changed…
Some languages with commas allow trailing comma, i.e. you can write a comma after each element, even if it might be the last one. I do love that. AFAIK it’s similar with ; separating statements, only there the trailing ; is very often even required.
I don’t really care about how code is indented that much, except for one instance. When brackets are unnecessarily placed on the same line as the items:
I like your last example, it shows that there are multiple attrsets in that list without using too much whitespace, and at the same time it keeps git diffs minimal.
In any case, in several languages there’s a de-facto formatter: Javascript has Prettier, Go has gofmt etc.
I would still use that form because it means that both items in the list and items in the attrsets can be moved around with minimal amount of work, in all editors. This encourages contributors of sorting things around in a way that makes sense. It also minimizes the merge conflicts. It’s not huge but I think it would make a difference over the size of nixpkgs.
I started work on nix-bikeshed [1] for this reason, that planned to
handle this (for the differences with a pretty-printer, see the
discussion at [2]). Unfortunately the work is currently blocked on [3]
being solved upstream at hnix, and I have too much stuff waiting
everywhere to take the time to try and handle this feature request
myself before I complete a few other projects…