The Uncompromising Nix Code Formatter
-
✔️ Fast
It's written in Rust and formats Nixpkgs in just a few seconds. 1
-
✔️ Powerful
We define a comprehensive style for all possible combinations of the Nix expression language.
-
✔️ Reliable
High coverage, battle tested.
From Nix's eyes, code is just the same. 2
-
✔️ Beautiful
Beauty is subjective, right?
We optimize for the wisdom of the crowd, which comes in big part from the 2.3 million lines of code of Nixpkgs.
-
✔️ Transparent
You won't notice the formatter after a while.
Humans care about the content, machines about the style!
Let's get Alejandra on our systems:
-
Nix with Flakes:
$ nix run github:kamadorueda/alejandra -- --help
-
Nix stable:
Pick one depending on your platform:
$ nix-env -ivA x86_64-darwin -f https://github.com/kamadorueda/alejandra/tarball/main $ nix-env -ivA x86_64-linux -f https://github.com/kamadorueda/alejandra/tarball/main
Then run with:
$ alejandra --help
- No.
See why Alejandra was created and a comparison between alternatives here.
Footnotes
-
Running on a machine with:
- CPU: 8 physical x Intel(R) Core(TM) i7-10700K, 16 logical
- MHz: 3800.00
- BogoMips: 7599.80
- Cache Size: 16384 KB
Results:
Logical Cores Seconds 1 45 2 22 4 14 8 10 16 11 -
The methodology to claim this is:
-
Checkout Nixpkgs and run:
$ nix-env -qaP --json --drv-path > before
-
Now format with Alejandra and run:
$ nix-env -qaP --json --drv-path > after
As of 2022-02-08, there are 47 differences in a set of 36278 derivations because of things like this:
goDeps = ./deps.nix;
Since
./deps.nix
was also formatted you get a semantical difference.This is something that should be solved on Nixpkgs and not a bug in Alejandra. For example:
↩ -