NixOS/nixfmt is a Developer Tools project on GitHub, written primarily in Haskell. It has 1.6k stars. The official formatter for Nix code
Snapshot summary built from the project's own GitHub metadata — there's no written TopGit review yet. The page will update automatically when a full review is published.
WHY NO REVIEW YET
TopGit writes full reviews for the most-starred, most-requested repositories. This page is a snapshot until then — see the READ ME tab for the original README in full.
Nixfmt is the official formatter for Nix language code.
The standard Nix format incorporates artistic formatting and is defined in standard.md.
Nixfmt is maintained by the Nix formatting team.
This document is the user documentation, see CONTRIBUTING.md for contributor documentation.
Installation
[!NOTE]
nixfmt can only process one file at a time.
Consider using a configuration helper for formatting a project.
In the environment
NixOS
To install nixfmt on NixOS for all users, add it to the environment.systemPackages configuration option:
If you want to use a stable version of nixfmt, then replace <version> with a tag from this repo. If you want to use an unstable version of nixfmt, then replace <version> with a commit hash from this repo.
Try to commit a badly formatted Nix file in order to make sure that everything works.
git mergetool
nixfmt provides a mode usable by git mergetool
via --mergetool that allows resolving formatting-related conflicts automatically in many cases.
git mergetool -t nixfmt .
# or, only for some specific files
git mergetool -t nixfmt FILE1 FILE2 FILE3
and some .nix files will probably get merged automagically.
Note that files that git merges successfully even before git mergetool
will be ignored by `git mergetool`.
If you don't like the result, run
git restore --merge .
# or, only for some specific files
git restore --merge FILE1 FILE2 FILE3
to return back to the unmerged state.
nix fmt (experimental)
nix fmt (part of the flakes experimental feature) can be configured to use nixfmt by setting the formatter flake output to nixfmt-tree (assuming a nixpkgs flake input exists):
nixfmt < input.nix – reads Nix code from stdin, formats it, and outputs to stdout
nixfmt file.nix – format the file in place
nixfmt --follow-symlinks link.nix – if link.nix is a symbolic link, format the regular file it points at (resolving any symlinks along the way).
Without --follow-symlinks, the symlink is replaced by a regular file holding the formatted result, and a warning is printed to stderr
Disabling Formatting
If you're using treefmt, you can include and exclude files via treefmt's configuration.
Within formatted nix files, you can use Nixfmt "directives" to enable and disable formatting from that line onwards.
How does NixOS/nixfmt compare to other Developer Tools projects?
NixOS/nixfmt is tracked by TopGit in the Developer Tools category, with 1.6k GitHub stars and written in Haskell. Browse the Developer Tools topic page on TopGit to compare it against similar projects by stars and activity.
Is NixOS/nixfmt open source?
Yes — NixOS/nixfmt ships under the MPL-2.0 license, which makes its source code freely readable (and, depending on license terms, forkable and reusable). Source: github.com/NixOS/nixfmt.
What else is in the Developer Tools space?
NixOS/nixfmt is tracked by TopGit under the Developer Tools category, alongside 3 GitHub-tagged topics. Trending and Topics pages list peer repositories of comparable stars and language.
What is NixOS/nixfmt?
NixOS/nixfmt (NixOS/nixfmt) is a Haskell project on GitHub. From the project's own README: The official formatter for Nix code
Where do I read more about NixOS/nixfmt?
This TopGit page is a snapshot — the READ ME tab shows the project's own README content (links stripped, images preserved). The GitHub repository at github.com/NixOS/nixfmt is the definitive source.
Why is NixOS/nixfmt categorized under Developer Tools?
TopGit places NixOS/nixfmt in the Developer Tools category based on its GitHub topics and description (tagged: "formatter", "haskell", "nix"). Categories are assigned from real repository metadata, not editorial guesswork.
Read full README in the tab above.
Curious whether nixfmt is right for you?
Let ChatGPT, Claude, or Perplexity look into it — click below and see what AI actually says about nixfmt.