mirror of
https://github.com/NixOS/nix
synced 2025-06-25 06:31:14 +02:00
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`.
(cherry picked from commit 6f71d8a9c2
)
This commit is contained in:
parent
bf0f35ec69
commit
6ba4b1d252
1 changed files with 3 additions and 25 deletions
|
@ -9,37 +9,15 @@ 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;
|
||||
};
|
||||
}
|
||||
```
|
||||
|
||||
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;
|
||||
formatter.x86_64-linux = nixpkgs.legacyPackages.${system}.nixfmt-tree;
|
||||
};
|
||||
}
|
||||
```
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue