From 94782f07c61563e2678da2b93ba0c0a6f2a174ec Mon Sep 17 00:00:00 2001 From: Jeremy Fleischman Date: Sun, 13 Apr 2025 11:30:18 -0700 Subject: [PATCH] Update `nix fmt` man page with official formatter example The current example relies upon [nixfmt's deprecated tree traversal behavior](https://github.com/NixOS/nixfmt/pull/240). The simplest alternative is the new `nixfmt-tree` wrapper for `nixfmt`/`treefmt`. --- src/nix/fmt.md | 28 ++++------------------------ 1 file changed, 4 insertions(+), 24 deletions(-) diff --git a/src/nix/fmt.md b/src/nix/fmt.md index b4693eb65..eee27fd9e 100644 --- a/src/nix/fmt.md +++ b/src/nix/fmt.md @@ -9,39 +9,19 @@ Flags can be forwarded to the formatter by using `--` followed by the flags. Any arguments will be forwarded to the formatter. Typically these are the files to format. -# Examples +# Example -With [nixpkgs-fmt](https://github.com/nix-community/nixpkgs-fmt): +To use the [official Nix formatter](https://github.com/NixOS/nixfmt): ```nix # flake.nix { outputs = { nixpkgs, self }: { - formatter.x86_64-linux = nixpkgs.legacyPackages.x86_64-linux.nixpkgs-fmt; + formatter.x86_64-linux = nixpkgs.legacyPackages.${system}.nixfmt-tree; }; } ``` -With [nixfmt](https://github.com/NixOS/nixfmt): - -```nix -# flake.nix -{ - outputs = { nixpkgs, self }: { - formatter.x86_64-linux = nixpkgs.legacyPackages.x86_64-linux.nixfmt-rfc-style; - }; -} -``` - -With [Alejandra](https://github.com/kamadorueda/alejandra): - -```nix -# flake.nix -{ - outputs = { nixpkgs, self }: { - formatter.x86_64-linux = nixpkgs.legacyPackages.x86_64-linux.alejandra; - }; -} -``` +See https://nix.dev/guides/recipes/autoformatting.html for more details. )""