Skip to main content

A Python library for parsing, manipulating, and reconstructing Nix source code with high-level abstractions while preserving formatting and comments in RFC-formatted code.

Project description

Nix-manipulator (Nima)

A Python library and tools for parsing, manipulating, and reconstructing Nix source code.

Overview

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.

Features and Goals

  • Ease of use - Simple CLI and API for common operations.
  • High-level abstractions make manipulating expressions easy.
  • Preserving formatting and comments in code that respects RFC-166.

Non-goals

  • Preserving eccentric formatting that does not respect RFC-166 and would add unnecessary complexity.

Targeted applications

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

Foundations

Nix-manipulator leverages tree-sitter , a multilingual concrete-syntax AST, and its Nix grammar tree-sitter-nix.

Project Status

The project is still in early-stage:

  • Not all Nix syntax is supported yet
  • Test-driven approach prevents regressions
  • CLI and API are still evolving and subject to change
  • 28991 / 39573 (73.26%) Nix files from nixpkgs could be parsed and reproduced

Target Audience

Intermediate Nix users and developers working with Nix code manipulation.

CLI Usage

Nix-manipulator provides a command-line interface for common operations:

Set a value in a Nix file

nima set -f package.nix version '"1.2.3"'

Set a boolean value

nima set -f package.nix doCheck true

Remove an attribute

nima rm -f package.nix doCheck

Test/validate that a Nix file can be parsed

nima test -f package.nix

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nix_manipulator-0.1.3.tar.gz (28.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

nix_manipulator-0.1.3-py3-none-any.whl (45.9 kB view details)

Uploaded Python 3

File details

Details for the file nix_manipulator-0.1.3.tar.gz.

File metadata

  • Download URL: nix_manipulator-0.1.3.tar.gz
  • Upload date:
  • Size: 28.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for nix_manipulator-0.1.3.tar.gz
Algorithm Hash digest
SHA256 dd2291fc6f1150437ec34dfcba16ed971bdb116537c13827f6e6d99a802fcde8
MD5 7a8b5a2d781fa45901778f2ff3061db7
BLAKE2b-256 28b4de70d2e9ac9c7b8b38c1bcb9df5feb2e6c9532d6cd16bbd84b620f9f0285

See more details on using hashes here.

Provenance

The following attestation bundles were made for nix_manipulator-0.1.3.tar.gz:

Publisher: release.yml on hoh/nix-manipulator

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file nix_manipulator-0.1.3-py3-none-any.whl.

File metadata

File hashes

Hashes for nix_manipulator-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 de7fade972daaf10cf2282397b03c9f6bdd144b2ffe959c93c99636e2a864153
MD5 2c38aaf9726424a1b04d89b18cdf2d0f
BLAKE2b-256 d9b42aca65a41b5b1c44c8488463307587d26b371b062b7048f9b1fe2c796008

See more details on using hashes here.

Provenance

The following attestation bundles were made for nix_manipulator-0.1.3-py3-none-any.whl:

Publisher: release.yml on hoh/nix-manipulator

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page