Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reformat Nixpkgs #322520

Open
6 of 7 tasks
infinisil opened this issue May 28, 2024 · 9 comments
Open
6 of 7 tasks

Reformat Nixpkgs #322520

infinisil opened this issue May 28, 2024 · 9 comments

Comments

@infinisil
Copy link
Member

infinisil commented May 28, 2024

The recent python reformatting has shown that people are eager to have a uniform style already. Even though nixfmt isn't fully stable yet, we can already go ahead and use it to reformat all of Nixpkgs. With future nixfmt changes it can be reformatted again.

@nixos-discourse
Copy link

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

https://discourse.nixos.org/t/formatting-team-meeting-2024-05-28/46126/1

@infinisil
Copy link
Member Author

First step towards this, shell.nix integration: #322512

@infinisil infinisil transferred this issue from NixOS/nixfmt Jun 26, 2024
@infinisil
Copy link
Member Author

After the above PR, here's the next one with first formatting pass! #322537 🎉

@myclevorname
Copy link
Contributor

Should we include formatter = forAllSystems (system: self.legacyPackages.${system}.nixfmt-rfc-style); in flake.nix?

@infinisil
Copy link
Member Author

Discussed in todays meeting:

  • @infinisil: Potential problem after full treewide reformat:
    • Open a PR introducing a new nix file, CI passes
    • We update the nixfmt version on the base branch
    • Merge the PR, CI broken for all other PRs, because the formatter changed
  • @infinisil: Proposed solution: Check formatting on pushes, if non-conformant, auto-commit to master a reformat

I'll implement this together with the upcoming full treewide reformat

@Atemu
Copy link
Member

Atemu commented Jan 7, 2025

Proposed solution: Check formatting on pushes, if non-conformant, auto-commit to master a reformat

This is only relevant for pushes regarding a change in the definition of the formatter used for CI, right?

Wouldn't it be better to just be more diligent to reformat nixpkgs (and/or have CI verify that fact) on the few occasions that the formatter definition is actually changed, without any auto-commit business?

@nixos-discourse
Copy link

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

https://discourse.nixos.org/t/formatting-team-meeting-2024-12-10-and-2025-01-07/58466/1

@infinisil
Copy link
Member Author

This is only relevant for pushes regarding a change in the definition of the formatter used for CI, right?

No it's for any random PR that introduces a new Nix file. The problem is that nothing forces CI to rerun before the PR can be merged, even if the formatter version has changed on master. So to the merger it looks like CI is green, but if you ran it again it would fail. This would be fixed by merge queues, but that needs some work. This is only a problem with PRs introducing new files, because all existing files will have to be reformatted to pass CI already in the PR that updates the formatter version.

@MattSturgeon
Copy link
Contributor

MattSturgeon commented Jan 7, 2025

The problem is that nothing forces CI to rerun before the PR can be merged, even if the formatter version has changed on master.

This could also be solved by a merge-queue, that runs CI on the merge-commit before actually merging. E.g. GitHub's or Mergify's queues.

But that's its own can of worms. And as we already saw in NixOS/org#39, it would need to be approached with caution.

EDIT: I just realised you'd already said this yourself in the message I was replying to...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Todo
Development

No branches or pull requests

6 participants