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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dd2291fc6f1150437ec34dfcba16ed971bdb116537c13827f6e6d99a802fcde8
|
|
| MD5 |
7a8b5a2d781fa45901778f2ff3061db7
|
|
| BLAKE2b-256 |
28b4de70d2e9ac9c7b8b38c1bcb9df5feb2e6c9532d6cd16bbd84b620f9f0285
|
Provenance
The following attestation bundles were made for nix_manipulator-0.1.3.tar.gz:
Publisher:
release.yml on hoh/nix-manipulator
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
nix_manipulator-0.1.3.tar.gz -
Subject digest:
dd2291fc6f1150437ec34dfcba16ed971bdb116537c13827f6e6d99a802fcde8 - Sigstore transparency entry: 478982239
- Sigstore integration time:
-
Permalink:
hoh/nix-manipulator@aa9b2ae30b90cdd8a76ad78643510d2b3721dbf2 -
Branch / Tag:
refs/tags/0.1.3 - Owner: https://github.com/hoh
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@aa9b2ae30b90cdd8a76ad78643510d2b3721dbf2 -
Trigger Event:
release
-
Statement type:
File details
Details for the file nix_manipulator-0.1.3-py3-none-any.whl.
File metadata
- Download URL: nix_manipulator-0.1.3-py3-none-any.whl
- Upload date:
- Size: 45.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
de7fade972daaf10cf2282397b03c9f6bdd144b2ffe959c93c99636e2a864153
|
|
| MD5 |
2c38aaf9726424a1b04d89b18cdf2d0f
|
|
| BLAKE2b-256 |
d9b42aca65a41b5b1c44c8488463307587d26b371b062b7048f9b1fe2c796008
|
Provenance
The following attestation bundles were made for nix_manipulator-0.1.3-py3-none-any.whl:
Publisher:
release.yml on hoh/nix-manipulator
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
nix_manipulator-0.1.3-py3-none-any.whl -
Subject digest:
de7fade972daaf10cf2282397b03c9f6bdd144b2ffe959c93c99636e2a864153 - Sigstore transparency entry: 478982254
- Sigstore integration time:
-
Permalink:
hoh/nix-manipulator@aa9b2ae30b90cdd8a76ad78643510d2b3721dbf2 -
Branch / Tag:
refs/tags/0.1.3 - Owner: https://github.com/hoh
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@aa9b2ae30b90cdd8a76ad78643510d2b3721dbf2 -
Trigger Event:
release
-
Statement type: