-
-
Notifications
You must be signed in to change notification settings - Fork 14.9k
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
Full treewide Nix format and enforcement [skip treewide] #380990
Draft
infinisil
wants to merge
6
commits into
NixOS:master
Choose a base branch
from
tweag:format-ikuzo
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
+1,010,246
−531,017
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
f203d08
to
347838f
Compare
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.
This enables `nix fmt`, though it won't be practically usable without also reformatting all files, which is done in a following commit.
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.
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.
And enable use of the auto-rebase script: https://github.com/NixOS/nixpkgs/tree/master/maintainers/scripts/auto-rebase
347838f
to
240326d
Compare
8 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
6.topic: cinnamon
Desktop environment
6.topic: continuous integration
Affects continuous integration (CI) in Nixpkgs, including Ofborg and GitHub Actions
6.topic: coq
"A formal proof management system"
6.topic: crystal
Programming language - https://crystal-lang.org/
6.topic: docker tools
6.topic: dotnet
Language: .NET
6.topic: emacs
Text editor
6.topic: erlang
6.topic: fetch
6.topic: flakes
The experimental Nix feature
6.topic: games
6.topic: GNOME
GNOME desktop environment and its underlying platform
6.topic: golang
6.topic: hardware
6.topic: haskell
6.topic: java
Including JDK, tooling, other languages, other VMs
6.topic: julia
6.topic: kernel
The Linux kernel
6.topic: lib
The Nixpkgs function library
6.topic: llvm/clang
Issues related to llvmPackages, clangStdenv and related
6.topic: lua
6.topic: LXQt
The Lightweight Qt Desktop Environment
6.topic: module system
About "NixOS" module system internals
6.topic: nixos
Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS
6.topic: nixos-container
Imperative and declarative systemd-nspawn containers
6.topic: nodejs
6.topic: nvidia
6.topic: ocaml
6.topic: pantheon
The Pantheon desktop environment
6.topic: php
6.topic: policy discussion
6.topic: printing
6.topic: python
6.topic: qt/kde
6.topic: R
6.topic: rocm
6.topic: ruby
6.topic: rust
6.topic: stdenv
Standard environment
6.topic: systemd
6.topic: tcl
6.topic: testing
Tooling for automated testing of packages and modules
6.topic: TeX
Issues regarding texlive and TeX in general
6.topic: vim
6.topic: xen-project
The Xen Project hypervisor
6.topic: xfce
The Xfce Desktop Environment
8.has: module (update)
This PR changes an existing module in `nixos/`
10.rebuild-darwin: 1-10
10.rebuild-linux: 1-10
backport release-24.11
Backport PR automatically
significant
Novel ideas, large API changes, notable refactorings, issues with RFC potential, etc.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is a huge step towards the full implementation of NixOS/rfcs#166 (ref NixOS/nixfmt#153)! Highlights:
treefmt
insidenix-shell
/nix develop
ornix fmt
to get the right formatting on all files, no more "these particular files need to be formatted"nixfmt
on auto-save or set up a pre commit hook to runtreefmt
This PR 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 reformat (#322537).
Merge conflicts caused by this commit can now also automatically be resolved while rebasing using the auto-rebase script.
This PR should be reviewed and approved by the @NixOS/nix-formatting team. Once ready, I'd like to schedule a merge party for this PR for the final review and merge. 🚀 🎉
Things done
treefmt
innix-shell
/nix develop
nix fmt
.git-blame-ignore-revs
(also needs constant updating)scripts/nixfmt-mergetool
nixfmt#277, that seems usefulPotential follow-up: There are cases where new files could be committed with the wrong formatting. If this becomes a sufficiently annoying problem, we should have some automation to automatically fix this. But let's see about that when we get there.
This work is funded by Tweag and Antithesis ✨
Add a 👍 reaction to pull requests you find important.