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

[Feature Request]: nix flake formatter output #433

Closed
3 tasks done
Familex opened this issue Sep 2, 2024 · 4 comments
Closed
3 tasks done

[Feature Request]: nix flake formatter output #433

Familex opened this issue Sep 2, 2024 · 4 comments
Assignees
Labels
System: Linux For Linux/BSD distributions Type: Enhancement New feature or request

Comments

@Familex
Copy link

Familex commented Sep 2, 2024

Checklist

  • I am using an up-to-date version.
  • I have read the documentation.
  • I have searched existing issues.

Description

outputs.formatter.<system> output used by nix fmt and formats all .nix files in project. I believe, the flake.nix is manually formatted at this point...

Solution

https://github.com/NixOS/nixfmt can be used

Alternatives

No response

@Familex Familex added the Type: Enhancement New feature or request label Sep 2, 2024
@CyanVoxel CyanVoxel added the System: Linux For Linux/BSD distributions label Sep 2, 2024
@zierf
Copy link
Contributor

zierf commented Sep 2, 2024

Just checked, I have nix lsp (nil) and formatter (nixpkgs-fmt) installed.

Using it on my provided Flake in #200 doesn't change anything in the file, it "is already formatted". And it doesn't seem too far off what @xarvex was using when we fixed video playback on Nix and enabled hardware acceleration (#417). I triggered the formatter and it was changing nothing (though I was expecting many little changes).

However, the formatter has some very strong opinions about line breaks near curly braces (e.g. after let statements) and doesn't care at all about those when merging lists ([ ]) ++ ([ ]).
I've seen better, the formatter is far from rustfmt.

I simply chose one at the time and I don't have any strong preferences. But this topic seems to provide an abundance of choices for different alternatives instead of a common standard tool.

I'm still rather open to this, but ideally it should be simple, automatic and available for most code editors out there.

@Familex
Copy link
Author

Familex commented Sep 2, 2024

@zierf nix fmt don't interact with code editor. It is just a command to run before commit.

I don't think it makes much difference which package we should use (because there is only one file). I'm simply suggesting to pin something.

I use alejandra as default nix formatter and it messes file up.

@xarvex
Copy link
Member

xarvex commented Sep 3, 2024

Thus far I have been using nixfmt-rfc-style as the formatter, as that is the official formatter used in nixpkgs. I can totally go ahead and expose the formatter attribute, I had forgotten about that.

@xarvex
Copy link
Member

xarvex commented Sep 3, 2024

Ouch, was a bit of a diff after that nix fmt, I think at some point I had removed the formatter from my PATH from my Nix configuration as I was putting all development tools into shells. But, at least the problem won't occur again. 😅

@xarvex xarvex closed this as completed in 3e2fb12 Sep 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
System: Linux For Linux/BSD distributions Type: Enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants