Brussels / 31 January & 1 February 2026

schedule

Nix-manipulator: Python library to manipulate Nix code with ease


Nima, the Nix Manipulator, is a new Python library and collection of tools for parsing, manipulating and reconstructing Nix source code.

This presentation will introduce the project, its original goals, key features, and practical applications. It will explore the tradeoffs and decisions made during development and demonstrate how to use its various features.

Context

Started during SaltSprint 2025, Nima 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.

Goals

  • Ease of use.
  • High-level abstractions make manipulating expressions easy.
  • Preserving formatting and comments in code that respects RFC-166.

Eccentric formatting that does not respect RFC-166 and would add unnecessary complexity may not be preserved.

Targeted applications

  • Updating values in Nix code by hand, scripts, pipelines, and frameworks.
  • Writing refactoring tools.
  • Interactive modifications from a REPL.

Foundations

Nima builds on tree‑sitter, a multilingual concrete‑syntax AST, with the tree‑sitter‑nix grammar providing lossless parsing of Nix files.

Project status

The project is still in early‑stage:

  • Most Nix syntax is supported, but not all everything yet.
  • Test-driven approach prevents regressions.
  • CLI and API stability is still evolving.

Links

Source: https://github.com/hoh/nix-manipulator Announcement: https://discourse.nixos.org/t/announcing-nix-manipulator-nima-structured-edits-for-nix-that-keep-formatting/68513/11

Speakers

Photo of Hugo Herter Hugo Herter

Links