Skip to content

[release-24.11] Full treewide Nix format and enforcement [skip treewide]#395018

Merged
infinisil merged 6 commits intoNixOS:release-24.11from
tweag:format-ikuzo-backport
Apr 1, 2025
Merged

[release-24.11] Full treewide Nix format and enforcement [skip treewide]#395018
infinisil merged 6 commits intoNixOS:release-24.11from
tweag:format-ikuzo-backport

Conversation

@infinisil
Copy link
Member

Backport of #380990, which contains all the details. Will also be merged in the merge party tomorrow.

I have a small script to make sure the backport mirrors the main PR, as well as linking to the correct commits.

This work is funded by Tweag and Antithesis

@infinisil infinisil force-pushed the format-ikuzo-backport branch from 9fb366a to 632c392 Compare March 31, 2025 21:18
@github-actions github-actions bot added 10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. labels Mar 31, 2025
infinisil and others added 6 commits April 1, 2025 20:10
Introduces treefmt with a simple nixfmt-rfc-style configuration to
format all Nix files.

This is only practically usable with the following commit that formats
all files accordingly.

(cherry picked from commit 398e74f)
This enables `nix fmt`, though it won't be practically usable without
also reformatting all files, which is done in a following commit.

(cherry picked from commit 5a8296d)
Changes the Nix format checking workflow to now strictly enforce
formatting of all Nix files using the treefmt setup introduced
in the pre-previous commit.

This is in [accordance with the approved RFC 166](https://github.com/NixOS/rfcs/blob/master/rfcs/0166-nix-formatting.md#reformat-nixpkgs).

Note that the "skip treewide" thing is no longer necessary, already
before, because there's nothing that would fail for treewide changes.
Previously the problem was that the GitHub API would be bombarded.

(cherry picked from commit 927521a)
Format all Nix files using the officially approved formatter,
making the CI check introduced in the previous commit succeed:

  nix-build ci -A fmt.check

This is the next step of the of the [implementation](NixOS/nixfmt#153)
of the accepted [RFC 166](NixOS/rfcs#166).

This commit will lead to merge conflicts for a number of PRs,
up to an estimated ~1100 (~33%) among the PRs with activity in the past 2
months, but that should be lower than what it would be without the previous
[partial treewide format](NixOS#322537).

Merge conflicts caused by this commit can now automatically be resolved while rebasing using the
[auto-rebase script](https://github.com/NixOS/nixpkgs/tree/8616af08d915377bd930395f3b700a0e93d08728/maintainers/scripts/auto-rebase).

If you run into any problems regarding any of this, please reach out to the
[formatting team](https://nixos.org/community/teams/formatting/) by
pinging @NixOS/nix-formatting.

(branch-equivalent to commit 374e6bc)
Copy link
Contributor

@jfly jfly left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

@infinisil infinisil merged commit 8e03b43 into NixOS:release-24.11 Apr 1, 2025
27 of 29 checks passed
@infinisil infinisil deleted the format-ikuzo-backport branch April 1, 2025 18:37
@nixos-discourse
Copy link

This pull request has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/nix-formatting-team-full-nixpkgs-reformat/61867/13

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants