After preparing for it throughout the year[1], we as the Nix formatting team are proud to announce the soon to be merged (almost) full reformat of nixpkgs with the following primary PR:
This PR will format all files without recent[2] activity to minimise merge conflicts on active PRs. Once files are formatted, CI will enforce them to stay formatted going forward.
We are coordinating asynchronously on Matrix and will hold a final review and merge party at Invalid date in Jitsi, feel free to join both!
Once merged, we will monitor for potential issues before going ahead with formatting the remaining files in the new year.
If you have any questions, concerns or problems with the reformatting process, let us know here as a reply or open a nixfmt issue or a Nixpkgs issue while pinging @NixOS/nix-formatting.
If you are interested in following the development of the tooling, feel free to join the Matrix room and the meetings, which are currently happening every second Tuesday with the next meeting at 2024-12-10T19:00:00Z. The nixfmt repository Readme is also worth mentioning, it contains a lot of instructions for configuring tools and editors (additions welcome!). We also appreciate more help with development.
Note that nixfmt-rfc-style is a not a Nixpkgs specific tool, youāre welcome to use it on your own projects.
Finally we would like to thank everybody involved in making this happen, starting from people involved in RFC 101 and the other formatter efforts such as alejandra, nixpkgs-fmt and the classic nixfmt, to everyone giving us feedback in the accepted RFC 166.
Thatās not a bug, thatās intended behaviour in accordance with the RFC.
Itās a trade-off between never absorbing anything and diff noise when absorbability changes. Diff noise is the lesser evil here; you do not want non-absorbed expressions everywhere, thatās insanely ugly and wasteful w.r.t. vertical space.
The diff noise isnāt that bad either as itās pretty easy to tell what happened and easy to verify nothing else changed at a glance.
To prevent it in situation where you think itās likely that itāll happen, I think weāll see patterns like
foo =
[ ]
++ [ ... ];
or
foo =
#
[ ... ];
emerge. I donāt like this either but, again, this is by far the lesser evil.
Correct me if Iām wrong but in the last meeting we (the team) decided that while this is an issue that has not been addressed, itās not blocking for an initial reformat and can be fixed at a later point.
Of course it can. If the formatter reformats lines that are not part of the actual diff, that adds noise to the diff; itās no longer just the lines that changed but other lines were āchangedā that didnāt actually meaningfully change and only had to be changed to fit the formatting rules.
There is none.
The best we could theoretically do would be to allow the user to specify whether they want the binding to be absorbed/compact or not so that we as humans can pre-emptively prevent diff noise where we think it is likely to happen.
That is imperfect and has its own additional issues though and I think the workaround patterns I described are preferable, particularly the no-op append.