nixfmt icon indicating copy to clipboard operation
nixfmt copied to clipboard

RFC 166 implementation tracking issue

Open infinisil opened this issue 1 year ago • 14 comments

Now that RFC 166 is accepted, let's commence with the implementation!

Here's a very rough todo-list, most of which will be fairly quick.

  • [x] Update README to mention WIP state: https://github.com/serokell/nixfmt/pull/154
  • [x] Create Nix formatting GitHub team: https://github.com/orgs/NixOS/teams/nix-formatting/members
    • [x] Add @Sereja313 to the team, couldn't do that myself since they're not already in the organisation. This was requested in the issue below
  • [x] Move repo under NixOS org: https://github.com/serokell/nixfmt/issues/155
  • [x] Decide on merge rules: https://github.com/NixOS/nixfmt/rules/523613?ref=refs%2Fheads%2Fmaster
  • [x] Create a team page in the repo: https://github.com/serokell/nixfmt/pull/156
  • Create a GitHub project board Let's only start using one if we feel the need for it
  • [x] Create a nixos.org page for the team: https://github.com/NixOS/nixos-homepage/pull/1337
  • [x] Move the RFCs initial standard format into the repo: https://github.com/NixOS/nixfmt/pull/158
  • [x] Merge https://github.com/serokell/nixfmt/pull/118
  • [x] Set up automated testing
    • Run test suite in CI: NixOS/nixfmt#172
    • Each PR needs to be tested on the entirety of Nixpkgs: https://github.com/NixOS/nixfmt/issues/163
  • [ ] Fully review the code
    • Check that it conforms to the specification
    • Document sufficiently
    • Simplify if possible
  • [ ] Tool documentation
  • [ ] Create a release and announce it
    • Marketing, celebration, Discourse, blog post, NixCon talk, etc.
    • Update Nixpkgs and Nix docs, e.g. contributor guide, etc.
  • [ ] Update nix fmt to point to nixfmt: https://github.com/NixOS/nix/pull/11252
  • [ ] Reformat Nixpkgs: https://github.com/NixOS/nixpkgs/issues/322520
    • Also on other repos
    • Also, Nix code in documentation and elsewhere

Ping @piegamesde @tomberek @0x4A6F @Sereja313 @dasJ

infinisil avatar Mar 12 '24 23:03 infinisil

Proposal: do reformatting in the NixOS org with a few non-nixpkgs repos first

tomberek avatar Mar 13 '24 01:03 tomberek

Proposal: After what @tomberek suggested is done and successful, do formatting of Nixpkgs in a subset of Nixpkgs first (i.e. pkgs/by-name/)

Atemu avatar Mar 13 '24 11:03 Atemu

https://github.com/Kreyren/nixos-config/blob/dc0dbb6f15c4d8656b26220645793a06d10fa3ea/nixos/users/kreyren/home/modules/prompts/starship/starship.nix#L3-L14 (best seen in raw)

RFC @infinisil Is this known issue that is actionable by RFC166? I read through it don't see it anywhere (if tabs are used it causes the prompt to be rendered with long indentation instead of the indentation being removed from the declaration, affects most of nix modules)

Kreyren avatar Mar 17 '24 12:03 Kreyren

This looks unlikely to be a desired output according to the RFC format. Now that the PR is merged, please simply open an issue for it.

piegamesde avatar Mar 17 '24 12:03 piegamesde

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

https://discourse.nixos.org/t/formatting-team-meeting-2024-03-19/41845/1

nixos-discourse avatar Mar 19 '24 20:03 nixos-discourse

This looks unlikely to be a desired output according to the RFC format. Now that the PR is merged, please simply open an issue for it. -- @piegamesde (https://github.com/NixOS/nixfmt/issues/153#issuecomment-2002441845)

Referencing comment by @roberth in https://github.com/NixOS/nix/issues/8874#issuecomment-1704358732

Got referred to RFC166 from RFC137 about this issue in relation to addressing https://github.com/NixOS/nix/issues/8874

Kreyren avatar Mar 20 '24 07:03 Kreyren

@Kreyren please just open a new issue with input, current output and desired output and I'll look at it. Simply linking to weird looking code does not give me enough context to understand the situation.

piegamesde avatar Mar 20 '24 09:03 piegamesde

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

https://discourse.nixos.org/t/tweag-nix-dev-update-56/43035/1

nixos-discourse avatar Apr 09 '24 12:04 nixos-discourse

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

https://discourse.nixos.org/t/nixf-tidy-static-semantic-linter-for-nix-help-me-to-integrate-it-with-github-actions-pr-reviews/43911/2

nixos-discourse avatar Apr 23 '24 09:04 nixos-discourse

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

https://discourse.nixos.org/t/enforcing-nix-formatting-in-nixpkgs/49506/3

nixos-discourse avatar Jul 23 '24 22:07 nixos-discourse

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

https://discourse.nixos.org/t/enforcing-nix-formatting-in-nixpkgs/49506/8

nixos-discourse avatar Jul 25 '24 14:07 nixos-discourse

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

https://discourse.nixos.org/t/satisfaction-survey-from-the-new-rfc-166-formatting/49758/1

nixos-discourse avatar Jul 28 '24 11:07 nixos-discourse

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

https://discourse.nixos.org/t/why-does-the-nixos-infrastructure-have-to-be-hosted-in-a-centralized-way/46789/36

nixos-discourse avatar Aug 06 '24 11:08 nixos-discourse

@infinisil et. al.: :heart: Thanks a lot for pushing this and the hard work on it! I am happy if that debate is soon over =) and we have some opiniated way to not disgress again and again into whitespace debates in PRs. Having a 90% solution is so much better then having nothing which puts Nixpkgs back to middleages.

gabyx avatar Aug 26 '24 06:08 gabyx

I made an extremely relevant nixfmt-mergetool script for nixfmt at https://github.com/NixOS/nixfmt/pull/277

usage: nixfmt-mergetool LOCAL BASE REMOTE MERGED

A `git-mergetool`-compatible merge tool that uses `nixfmt` to merge more
stuff.

This tool rejects all non-`.nix` files, for `.nix` files it simply

- calls `nixfmt` on its first three inputs, followed by
- running `git merge-file` on the same inputs, followed by
- running `nixfmt` on the result.

Put the following to your `~/.gitconfig`:

[mergetool "nixfmt"]
    cmd = nixfmt-mergetool "$LOCAL" "$BASE" "$REMOTE" "$MERGED"
    trustExitCode = true

Then, when `git merge` or `git rebase` fails, run

git mergetool -t nixfmt .
# or, only for some specific files
git mergetool -t nixfmt FILE1 FILE2 FILE3

and some `.nix` files will probably get merged automagically.

Note that files that `git` merges successfully even before `git mergetool`
will be ignored by `git mergetool`.

If you don't like the result, run

git restore --merge .
# or, only for some specific files
git restore --merge FILE1 FILE2 FILE3

to return back to the unmerged state.

oxij avatar Jan 23 '25 13:01 oxij

We're calling this done! nixpkgs will use the stable release soon, see https://github.com/NixOS/nixpkgs/pull/427437.

jfly avatar Jul 22 '25 18:07 jfly