nix-ast
A Nix library, built on Haskell's hnix parser, that parses Nix expressions into a structured AST, lets you traverse and transform it with pure Nix functions, and renders or evaluates the result, plus a command-line tool for the same operations.
nix-ast is a library that gives Nix code access to a full abstract-syntax-tree API from within Nix itself. It uses Import From Derivation to bridge to a Haskell parser and evaluator (hnix) internally, so a Nix expression can be parsed, inspected, transformed and rendered back to source without leaving the Nix language.
The library exposes three groups of functions: IFD-based parse, render and eval that bridge to the Haskell parser and evaluator; pure Nix conversions between native values and AST nodes (toAST and fromAST) that need no IFD; and helpers for pattern matching, syntax and traversal once a tree is built. A bundled CLI tool (nix-ast eval, parse and render) exposes the same operations for shell and pipe workflows. It is written in Haskell and distributed as a Nix flake.