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

nix fmt should have a --dry-run option or similar #6918

Open
kjeremy opened this issue Aug 17, 2022 · 2 comments · May be fixed by #8063
Open

nix fmt should have a --dry-run option or similar #6918

kjeremy opened this issue Aug 17, 2022 · 2 comments · May be fixed by #8063
Labels
feature Feature request or proposal new-cli Relating to the "nix" command

Comments

@kjeremy
Copy link
Contributor

kjeremy commented Aug 17, 2022

Is your feature request related to a problem? Please describe.
nix fmt is great for formatting a flake but it would be nice if we could check if nix fmt would perform any operations. This would be useful in CI for example or integrated into nix flake check.

Describe the solution you'd like
I'd like to see a --dry-run or similar flag passed to nix fmt that would return a status indicating if a nix fmt would change any files.

Describe alternatives you've considered
Calling the specified formatter manually and hoping it has this feature implemented.

Additional context
We are interested in adding this to our project CI to ensure that nix files are formatted properly when committed.

@fricklerhandwerk fricklerhandwerk added feature Feature request or proposal new-cli Relating to the "nix" command and removed improvement labels Sep 12, 2022
@diktomat
Copy link

diktomat commented Mar 4, 2023

Instead of --dry-run, I'd like to propose -c | --check, as that is the flag used for this purpose in all of nixfmt, nixpkgs-fmt (only long opt) and alejandra.

@fzakaria
Copy link
Contributor

fzakaria commented Aug 4, 2024

You can do nix fmt -- --check . now -- is that the same?
I guess running it as nix flake check would be the thing to do .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Feature request or proposal new-cli Relating to the "nix" command
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants