1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-07-06 21:41:48 +02:00

fix(nix fmt): remove the default "." argument

When `nix fmt` is called without an argument, Nix appends the "." argument before calling the formatter. The comment in the code is:
> Format the current flake out of the box

This also happens when formatting sub-folders.

This means that the formatter is now unable to distinguish, as an interface, whether the "." argument is coming from the flake or the user's intent to format the current folder. This decision should be up to the formatter.

Treefmt, for example, will automatically look up the project's root and format all the files. This is the desired behaviour. But because the "." argument is passed, it cannot function as expected.
This commit is contained in:
zimbatm 2024-09-05 10:29:48 +02:00
parent 5bfe198ad5
commit c4766d7b8b
4 changed files with 28 additions and 13 deletions

View file

@ -40,14 +40,8 @@ struct CmdFmt : SourceExprCommand {
Strings programArgs{app.program};
// Propagate arguments from the CLI
if (args.empty()) {
// Format the current flake out of the box
programArgs.push_back(".");
} else {
// User wants more power, let them decide which paths to include/exclude
for (auto &i : args) {
programArgs.push_back(i);
}
for (auto &i : args) {
programArgs.push_back(i);
}
// Release our references to eval caches to ensure they are persisted to disk, because