The pedantic nix formatter https://swarsel.github.io/pedantix/
  • Rust 87.5%
  • Nix 9.6%
  • Emacs Lisp 2.9%
Find a file
2026-10-28 16:46:05 +01:00
.github/workflows feat: add documentation page 2026-07-18 23:04:11 +02:00
docs feat: allow skipping unparseable files 2026-10-28 16:36:45 +01:00
emacs fix: fingerprinting of empty collections 2026-09-05 04:01:01 +02:00
examples feat: allow skipping unparseable files 2026-10-28 16:36:45 +01:00
nix feat: use conventional pre-commits pre-commit hook 2026-07-31 02:24:22 +02:00
presets presets/nixpkgs-package: add name as attr for sorting 2026-08-04 09:52:11 +02:00
src fix: tolerate comment reformatting 2026-10-28 16:46:05 +01:00
tests feat: allow skipping unparseable files 2026-10-28 16:36:45 +01:00
.gitignore feat: support attribute set flattening 2026-07-20 23:15:12 +02:00
.pre-commit-hooks.yaml feat: add pre-commit framework hook manifest 2026-07-23 10:05:46 +02:00
Cargo.lock fix: fingerprinting of empty collections 2026-09-05 04:01:01 +02:00
Cargo.toml fix: fingerprinting of empty collections 2026-09-05 04:01:01 +02:00
example.nix feat: Initial release 2026-07-18 19:04:18 +02:00
flake.lock feat: Initial release 2026-07-18 19:04:18 +02:00
flake.nix feat: use conventional pre-commits pre-commit hook 2026-07-31 02:24:22 +02:00
LICENSE Add MIT License to the project 2026-07-19 11:25:40 +02:00
pedantix.toml feat: (un-)quote (valid) identifiers 2026-07-31 01:45:07 +02:00
README.md feat: support per-file overrides 2026-08-25 08:47:50 +02:00

pedantix

pedantix is the pedantic Nix formatter.

It was bothering me that in my NixOS configuration, I was never consistent in ordering my module arguments, some being { lib, config, pkgs, ... } and some others being { config, lib, pkgs, ... }, you get the idea. Also I had grown tired of statix' repeated_keys error. Lastly, due to the nature of the nix language, I do not think there is much value in custom ordering of attributes except for in let bindings (I guess you could make a case for rec as well).

pedantix does this for you while staying compliant with your formatter of choice (tested with nixfmt(-rs), alejandra, and nixpkgs-fmt). I guess you can consider it a cherry on top :)

Here are some of its features (everything is optional):

  • ordering of function arguments
  • ordering of attributes
  • ordering of inherits
  • ordering of let bindings
  • ordering of lists (use with caution!)
  • merging of repeated keys (this does not fix broken evaluations)
  • flattening of attribute sets with a single entry
  • (un-)quoting of (valid) identifiers
  • enforcing of blank lines in between attribute sets
  • overrides for arbitrary attribute/file paths

Try it now

(this will not modify your file, but only show you how it would look when formatted with pedantix)

nix run github:Swarsel/pedantix < your-file.nix

Click here to see the full Documentation