diff options
author | Kevin Amado <kamadorueda@gmail.com> | 2022-03-11 08:57:28 -0500 |
---|---|---|
committer | Kevin Amado <kamadorueda@gmail.com> | 2022-03-11 10:00:19 -0500 |
commit | 2191dab65726012b057402e13132dd7a062d8440 (patch) | |
tree | a4bc1050eadf249d94009be6c493a27f37800572 /src/nix/fmt.md | |
parent | aee56e0f895e7b9890d1ec948b24c75478f9e88e (diff) |
nix-fmt: add command
Diffstat (limited to 'src/nix/fmt.md')
-rw-r--r-- | src/nix/fmt.md | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/src/nix/fmt.md b/src/nix/fmt.md new file mode 100644 index 000000000..1c78bb36f --- /dev/null +++ b/src/nix/fmt.md @@ -0,0 +1,53 @@ +R""( + +# Examples + +With [nixpkgs-fmt](https://github.com/nix-community/nixpkgs-fmt): + +```nix +# flake.nix +{ + outputs = { nixpkgs, self }: { + formatter.x86_64-linux = nixpkgs.legacyPackages.x86_64-linux.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): + +```nix +# flake.nix +{ + outputs = { nixpkgs, self }: { + formatter.x86_64-linux = nixpkgs.legacyPackages.x86_64-linux.nixfmt; + }; +} +``` + +- Format specific files: `$ nix fmt ./file1.nix ./file2.nix` + +With [Alejandra](https://github.com/kamadorueda/alejandra): + +```nix +# flake.nix +{ + outputs = { nixpkgs, self }: { + formatter.x86_64-linux = nixpkgs.legacyPackages.x86_64-linux.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. + +)"" |