-
Notifications
You must be signed in to change notification settings - Fork 8
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
Add formatter and CI formatting check #60
Conversation
Cool! Some quick ideas, I am on my phone right now so can't do a proper review yet:
|
Fuck whyyy. When I
See: NixOS/nixfmt#151 So we either have to depend on https://github.com/numtide/treefmt-nix (not a fan of adding a flake dependency for such a trivial thing), or roll our own with something like |
Yeah I saw that warning. It's coming from the rfc formatter (https://github.com/NixOS/nixfmt/blob/a4639036723e510d8331124c80d9ca14dd7aba02/main/Main.hs#L121). Imo this is a really dumb warning, since |
To be honest, you would probably be better off using a more stable formatter like alejandra or nixpkgs-fmt. The readme for the rfc formatter indicates it is still extremely unstable software. |
What about something like this for formatting/checking all files? This should handle both tracked and untracked files, and also respect git ls-files --cached --others --exclude-standard -z -- '*.nix' | xargs -0 nixfmt Regarding nixfmt, I fear that it's in the "technically experimental but all other reasonable options are already deprecated" territory, same as flakes. They are already reformatting huge swaths of nixpkgs with it, look at this PR from 5 days ago (+706,935 -433,885): NixOS/nixpkgs#322537 |
I suppose something like that would work just fine. For now it seems this is only a warning, so maybe it's not worth worrying over? |
39cf0dc
to
28e781f
Compare
Pushed a change introducing TODOs:
|
Also |
Hey, (a) nixfmt maintainer here! We very intentionally deprecated that recursive mode, because the details get tricky, but it's all behavior generic for all formatters, making it perfect for treefmt. This includes:
If you want to see treefmt-nix in practice, you can check out the config in nixfmt itself. The definition of Anyways, totally up to you how you want to handle it, but feel free to let us know of any problems or suggestions for improvement in the nixfmt issue tracker :) Oh and you can consider nixfmt stable, we plan to make the 1.0 release very soon, the formatting should only change in minor ways going forward. |
28e781f
to
00d8bd3
Compare
@infinisil wow, definitely did not expect you to comment here, thank you for chiming in :) It's good to hear that nixfmt will be "officially" stabilized soon. Yeah, fine, I did check out treefmt and treefmt-nix since you are recommending it. I read through some of the code in both, my only nitpick is that the flake example in the treefmt-nix readme is broken. ( ( And at that point I might as well start using it here already. Getting some experience with it and learning any of its quirks on a simpler project is probably more valuable than avoiding the extra dependency in favor of the one-liner that technically would also work in this particular scenario. I updated the PR to use treefmt-nix. |
00d8bd3
to
6416acf
Compare
Co-authored-by: György Kurucz <[email protected]>
6416acf
to
593ffbf
Compare
593ffbf
to
eed57f6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approved from my side. @eureka-cpu I did quite a few changes to your original PR, so you should also take a look to see if you agree with all of my changes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM thanks for the refactors @kuruczgy
Closes #56
Reformats the project using the RFC style formatter. Specifies the formatter package in the flake. Adds a check to CI on pull request that fails if nix files are not properly formatted.