Merge pull request #11613 from NixOS/nix-fmt-doc

doc/nix fmt: Do not document behavior we do not control
This commit is contained in:
Valentin Gagarin 2024-09-29 20:48:43 +02:00 committed by GitHub
commit 79138183a9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 10 additions and 16 deletions

View File

@ -1,5 +1,14 @@
R""( R""(
# Description
`nix fmt` calls the formatter specified in the flake.
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 # Examples
With [nixpkgs-fmt](https://github.com/nix-community/nixpkgs-fmt): With [nixpkgs-fmt](https://github.com/nix-community/nixpkgs-fmt):
@ -13,10 +22,6 @@ With [nixpkgs-fmt](https://github.com/nix-community/nixpkgs-fmt):
} }
``` ```
- Format the current flake: `$ nix fmt`
- Format a specific folder or file: `$ nix fmt ./folder ./file.nix`
With [nixfmt](https://github.com/serokell/nixfmt): With [nixfmt](https://github.com/serokell/nixfmt):
```nix ```nix
@ -28,8 +33,6 @@ With [nixfmt](https://github.com/serokell/nixfmt):
} }
``` ```
- Format specific files: `$ nix fmt ./file1.nix ./file2.nix`
With [Alejandra](https://github.com/kamadorueda/alejandra): With [Alejandra](https://github.com/kamadorueda/alejandra):
```nix ```nix
@ -41,13 +44,4 @@ With [Alejandra](https://github.com/kamadorueda/alejandra):
} }
``` ```
- Format the current flake: `$ nix fmt`
- Format a specific folder or file: `$ nix fmt ./folder ./file.nix`
# Description
`nix fmt` will rewrite all Nix files (\*.nix) to a canonical format
using the formatter specified in your flake.
)"" )""

View File

@ -11,7 +11,7 @@ cp ./simple.nix ./simple.builder.sh ./fmt.simple.sh ./config.nix "$TEST_HOME"
cd "$TEST_HOME" cd "$TEST_HOME"
nix fmt --help | grep "Format" nix fmt --help | grep "forward"
cat << EOF > flake.nix cat << EOF > flake.nix
{ {