Skip to content

Commit f4e5697

Browse files
committed
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.
1 parent 5bfe198 commit f4e5697

File tree

1 file changed

+2
-8
lines changed

1 file changed

+2
-8
lines changed

src/nix/fmt.cc

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,8 @@ struct CmdFmt : SourceExprCommand {
4040
Strings programArgs{app.program};
4141

4242
// Propagate arguments from the CLI
43-
if (args.empty()) {
44-
// Format the current flake out of the box
45-
programArgs.push_back(".");
46-
} else {
47-
// User wants more power, let them decide which paths to include/exclude
48-
for (auto &i : args) {
49-
programArgs.push_back(i);
50-
}
43+
for (auto &i : args) {
44+
programArgs.push_back(i);
5145
}
5246

5347
// Release our references to eval caches to ensure they are persisted to disk, because

0 commit comments

Comments
 (0)