Home

Awesome

rnix-parser Crates.io Chat on Matrix

rnix is a parser for the Nix language written in Rust.

This can be used to manipulate the Nix AST and can for example be used for:

and a lot more!

rnix nowadays uses @matklad's rowan crate to ensure:

Demo

Examples can be found in the examples/ directory.

You may also want to see nix-explorer: An example that highlights AST nodes in Nix code. This demonstrates how whitespaces and commands are preserved.

Hacking

Tests can be run with cargo test.

In order to update all .expect-files to the currently expected results, you may run UPDATE_TESTS=1 cargo test.

You can parse Nix expressions from standard input using the from-stdin example. To try that, run the following in your shell:

echo "[hello nix]" | cargo run --quiet --example from-stdin

Release Checklist

RIP jd91mzm2

Sadly, the original author of this project, @jD91mZM2 has passed away. His online presence was anonymous and what we have left is his code. This is but one of his many repos that he contributed to.