Nix 2.93.3
Lix: A modern, delicious implementation of the Nix package manager; unstable internal interfaces
Loading...
Searching...
No Matches
fmt

R""(

Note: this command's interface is based heavily around installables, which you may want to read about first (nix --help).

Examples

With nixpkgs-fmt:

# 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:

# 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:

# 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.

)""