Open whentze opened 9 months ago
It would also be good to have flags to nix fmt
, and options for formatter
in the flake.nix
file, which control which files are formatted. e.g. --exclude
nix fmt
is almost nix run
.
If this is the kind of bug report we can expect from this feature, with formatters having varying behaviors when it comes to files and directories, this would be another reason to remove nix fmt
.
With something like nix run
, there would be no expectations that the formatter magically behaves correctly; just that it gets invoked. (Also: nix dev
)
Here's the other issue
It would also be good to have flags to
nix fmt
, and
We'd have scope creep until we've duplicated treefmt
, but worse.
If this is the kind of bug report we can expect from this feature, with formatters having varying behaviors when it comes to files and directories, this would be another reason to remove nix fmt.
Huh, interesting. I had somehow assumed that nix fmt
, like other flake-based commands, would work on the flake tree, which does not have .git
, I think.
Describe the bug
If you make a git branch/tag whose name ends in .nix, git creates files like
.git/refs/heads/add-stuff-to-default.nix
that don't contain nix code but end up being "formatted" bynix fmt
anyway. This leads to a corrupted git repository and very confusing messages like:Steps To Reproduce
git switch -C add-stuff-to-default.nix
nix fmt
Expected behavior
I think
nix fmt
should entirely ignore.git
. Perhaps it should also skip gitignored stuff, but I'm not sure.nix-env --version
outputnix-env (Nix) 2.13.6