1
Fork 0
mirror of https://github.com/RGBCube/alejandra synced 2025-09-12 17:47:58 +00:00
No description
Find a file
2022-02-18 13:02:27 -05:00
front feat: correct aarch64-darwin build 2022-02-17 19:16:23 -05:00
installers feat: release 0.2.0 2022-02-17 01:48:22 -05:00
integrations/vscode feat: update dependencies 2022-02-17 01:20:08 -05:00
src feat: more uniform family of elements 2022-02-18 13:02:27 -05:00
tests feat: more uniform family of elements 2022-02-18 13:02:27 -05:00
.editorconfig chore: add a more ergonomic (and cleaner) devshell 2022-01-30 16:45:43 -05:00
.envrc refactor: remove nix3 alias 2022-02-16 21:40:16 -05:00
.gitignore feat: add wasm site 2022-02-13 13:51:20 -05:00
buildkite.yaml feat: correct aarch64-darwin build 2022-02-17 19:16:23 -05:00
Cargo.lock feat: release 0.2.0 2022-02-17 01:48:22 -05:00
Cargo.toml feat: release 0.2.0 2022-02-17 01:48:22 -05:00
CHANGELOG.md feat: inline end at 2022-02-18 12:14:05 -05:00
default.nix feat: correct aarch64-darwin build 2022-02-17 19:16:23 -05:00
flake.lock feat: correct aarch64-darwin build 2022-02-17 19:16:23 -05:00
flake.nix fix: add cargo to build env 2022-02-18 12:20:50 -05:00
pre-commit.sh fixup: re-add cargo & treefmt 2022-01-30 19:45:15 -05:00
README.md fix: relative path 2022-02-14 22:29:53 -05:00
rustfmt.toml feat: format toml 2022-01-30 13:26:52 -05:00
treefmt.toml feat: correct aarch64-darwin build 2022-02-17 19:16:23 -05:00
UNLICENSE feat: release into the public domain 2022-01-09 22:14:23 -05:00

Alejandra 💅

The Uncompromising Nix Code Formatter

CI/CD Coverage License: The Unlicense style: Alejandra

Try it on your browser! here

Features

  • ✔️ 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 started from the wisdom of the crowd, which comes in big part from the 2.3 million lines of code of Nixpkgs. Then we applied the feedback of developers who have used Nix on a day to day basis for several years.

  • ✔️ Transparent

    You won't notice the formatter after a while.

    Humans care about the content, machines about the style!

  • ✔️ Native

    We integrate with common code editors:

Getting started

On the web editor

Please visit: kamadorueda.github.io/alejandra

Prebuilt binaries

You can download a binary for your platform from the releases section, make it executable and have fun!

Alternatively there is an automated method. It needs: curl, sh and chmod:

  • On any x86_64 Linux:

    $ curl https://raw.githubusercontent.com/kamadorueda/alejandra/main/installers/x86_64-linux.sh | sh
    
  • On any AArch64/ARM64 Linux:

    $ curl https://raw.githubusercontent.com/kamadorueda/alejandra/main/installers/aarch64-linux.sh | sh
    

Then run Alejandra with:

$ ./alejandra --help

or:

$ /path/to/alejandra --help

Nix installation

  • Nix with Flakes:

    $ nix profile install github:kamadorueda/alejandra
    
  • Nix stable:

    Pick one depending on your platform:

    $ nix-env -ivA aarch64-darwin -f https://github.com/kamadorueda/alejandra/tarball/main
    $ nix-env -ivA aarch64-linux -f https://github.com/kamadorueda/alejandra/tarball/main
    $ 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 Alejandra with:

$ alejandra --help

Do I need to configure anything?

  • No.

Discussion

Cool libraries

Alternatives

See why Alejandra was created and a comparison between alternatives here.

Versioning

We use semver to version Alejandra.

Our public API consists of:

  • The formatting rules (a.k.a. the style).
  • The CLI tool ($ alejandra), command line flags, positional arguments, and stdout.

Changelog

Please see: CHANGELOG.md.

Footnotes


  1. 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
    ↩︎
  2. The methodology to claim this is:

    1. Checkout Nixpkgs and run:

      $ nix-env -qaP --json --drv-path > before
      
    2. 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:

    ↩︎