A Python library and tools for parsing, manipulating, and reconstructing Nix source code.
Started during SaltSprint 2025, Nix-manipulator aims to fill the absence of tools for easily updating and editing Nix code. Popular tools such as nix-update rely on simple string replacement or regular expressions for updating Nix code.
- Ease of use - Simple API for common operations.
- High-level abstractions make manipulating expressions easy.
- Preserving formatting and comments in code that respects RFC-166.
- Preserving eccentric formatting that does not respect RFC-166 and would add unnecessary complexity.
- Updating values in Nix code by hand, scripts, pipelines, and frameworks.
- Writing refactoring tools.
- Interactive modifications from a REPL.
Nix-manipulator leverages tree-sitter , a multilingual concrete-syntax AST, and its Nix grammar tree-sitter-nix.
The project is still in early-stage:
- Not all Nix syntax is supported yet
- Test-driven approach prevents regressions
- API are still evolving and subject to change
- 28991 / 39573 (73.26%) Nix files from nixpkgs could be parsed and reproduced
Intermediate Nix users and developers working with Nix code manipulation.