aboutsummaryrefslogtreecommitdiff
path: root/doc/manual
diff options
context:
space:
mode:
authorJonas Chevalier <zimbatm@zimbatm.com>2024-09-30 16:10:32 +0000
committerGerrit Code Review <gerrit@localhost>2024-09-30 16:10:32 +0000
commita16ceb9411c57993d811c6bebb517742fe3d34e3 (patch)
treea3570018ce062afe1684702308d3359f48759a85 /doc/manual
parentaa33c34c9be074c9452976aa96d71091325c83ea (diff)
parent2265536e853437dc1f36f9c7a20eb2ebeac6ecaa (diff)
Merge "fix(nix fmt): remove the default "." argument" into main
Diffstat (limited to 'doc/manual')
-rw-r--r--doc/manual/change-authors.yml3
-rw-r--r--doc/manual/rl-next/nix-fmt-default-argument.md38
2 files changed, 41 insertions, 0 deletions
diff --git a/doc/manual/change-authors.yml b/doc/manual/change-authors.yml
index e18abada1..60c0924c7 100644
--- a/doc/manual/change-authors.yml
+++ b/doc/manual/change-authors.yml
@@ -147,3 +147,6 @@ winter:
yshui:
github: yshui
+
+zimbatm:
+ github: zimbatm
diff --git a/doc/manual/rl-next/nix-fmt-default-argument.md b/doc/manual/rl-next/nix-fmt-default-argument.md
new file mode 100644
index 000000000..41b8f85bd
--- /dev/null
+++ b/doc/manual/rl-next/nix-fmt-default-argument.md
@@ -0,0 +1,38 @@
+---
+synopsis: Removing the `.` default argument passed to the `nix fmt` formatter
+issues: []
+prs: [11438]
+cls: [1902]
+category: Breaking Changes
+credits: zimbatm
+---
+
+The underlying formatter no longer receives the ". " default argument when `nix fmt` is called with no arguments.
+
+This change was necessary as the formatter wasn't able to distinguish between
+a user wanting to format the current folder with `nix fmt .` or the generic
+`nix fmt`.
+
+The default behaviour is now the responsibility of the formatter itself, and
+allows tools such as treefmt to format the whole tree instead of only the
+current directory and below.
+
+This may cause issues with some formatters: nixfmt, nixpkgs-fmt and alejandra currently format stdin when no arguments are passed.
+
+Here is a small wrapper example that will restore the previous behaviour for such a formatter:
+
+```nix
+{
+ outputs = { self, nixpkgs, systems }:
+ let
+ eachSystem = nixpkgs.lib.genAttrs (import systems) (system: nixpkgs.legacyPackages.${system});
+ in
+ {
+ formatter = eachSystem (pkgs:
+ pkgs.writeShellScriptBin "formatter" ''
+ if [[ $# = 0 ]]; set -- .; fi
+ exec "${pkgs.nixfmt-rfc-style}/bin/nixfmt "$@"
+ '');
+ };
+}
+```