Alejandra is written in Rust, has more tests than nixfmt, and handles non-trivial code examples in Nix better.
This works, and is a result of the work done by NotAShelf.