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.2.tar.gz (27.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.2-py3-none-any.whl (43.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: nix_manipulator-0.1.2.tar.gz
  • Upload date:
  • Size: 27.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.2.tar.gz
Algorithm Hash digest
SHA256 b0ad2507c40eef029c6548c36fec8408cea9fa827fb39e89979c92f3ce6080d3
MD5 cbd9760921e6533d30aca58276da3736
BLAKE2b-256 3ead5b3011929f802d346e6010f87d8b70e2a35ea3ba18dbdacd1ac1def6a729

See more details on using hashes here.

Provenance

The following attestation bundles were made for nix_manipulator-0.1.2.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.2-py3-none-any.whl.

File metadata

File hashes

Hashes for nix_manipulator-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 26647e23a2cd05c830149de4eb58bbcde6455d53d8e8e29e973ed756ea74c416
MD5 3467da032386efffccbe5f2890ccb94a
BLAKE2b-256 1594c68e42692a70543a468053862011efa32636768d2242cea8b42529ac299a

See more details on using hashes here.

Provenance

The following attestation bundles were made for nix_manipulator-0.1.2-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