nixfmt: An opinionated formatter for Nix

[ development, library, mpl ] [ Propose Tags ]

A formatter for Nix that ensures consistent and clear formatting by forgetting all existing formatting during parsing.

[Skip to Readme]


Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees


Versions [RSS] 0.3.0, 0.4.0, 0.5.0
Change log
Dependencies base (>=4.12.0 && <4.17), cmdargs (>=0.10.20 && <0.11), directory (>=1.3.3 && <1.4), filepath (>=1.4.2 && <1.5), ghcjs-base (>=0.2.0 && <0.3), megaparsec (>=9.0.1 && <9.3), nixfmt, parser-combinators (>=1.0.3 && <1.4), safe-exceptions (>=0.1.7 && <0.2), text (>=1.2.3 && <1.3), unix (>=2.7.2 && <2.8) [details]
License MPL-2.0
Copyright 2022 Serokell, 2022 Lars Jellema
Author Lars Jellema
Category Development
Home page
Bug tracker
Source repo head: git clone git://
Uploaded by LarsJellema at 2022-03-19T14:42:03Z
Distributions NixOS:0.5.0
Executables js-interface, nixfmt
Downloads 1011 total (14 in the last 30 days)
Rating 1.75 (votes: 1) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2022-03-19 [all 1 reports]

Readme for nixfmt-0.5.0

[back to package description]


nixfmt is a formatter for Nix code, intended to easily apply a uniform style.

You are encouraged to test this out on your code and submit any undesirable formatting you find as an issue

Build Status Cachix


  • nixfmt is in nixpkgs master as of 2019-09-04:

    nix-env -iA nixpkgs.nixfmt
  • To get the most recent version, install from master:

    # Optional: use cachix to get cached builds even for master
    cachix use nixfmt
    nix-env -f -i
  • Nix with flakes

    nix profile install github:serokell/nixfmt


With Nix

Haskell dependencies will be built by Nix.

  • Enter nix-shell
  • Build with cabal new-build

Without Nix

Haskell dependencies will be built by Cabal.

  • Build with cabal new-build


  • nixfmt < input.nix – reads Nix code form stdin, formats it, and outputs to stdout
  • nixfmt file.nix – format the file in place

For Contributors

We welcome issues and pull requests on GitHub.

About Serokell

nixfmt is maintained and funded with ❤️ by Serokell. The names and logo for Serokell are trademark of Serokell OÜ.

We love open source software! See our other projects or hire us to design, develop and grow your idea!