Back to directory

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

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.

More in CLI tools

See all 181
  • grev

    github.com

    A set of Unix coreutils-style filters — grep, sort, cut and more — that answer a plain-language question about each record instead of matching a pattern, using a small decision model.

  • A Node.js script that exports a Google Doc to HTML and CSS with high fidelity, preserving headings, spacing, alignment, bullet lists, images and right-to-left text.

  • gpusched

    github.com

    A VRAM-aware GPU job scheduler for a single machine: declare how much memory each shell command needs, and it places jobs the moment a GPU has room and reports when a guess was wrong.