Name | nix-manipulator JSON |
Version |
0.1.3
JSON |
| download |
home_page | None |
Summary | A Python library for parsing, manipulating, and reconstructing Nix source code with high-level abstractions while preserving formatting and comments in RFC-formatted code. |
upload_time | 2025-09-06 12:35:16 |
maintainer | None |
docs_url | None |
author | None |
requires_python | >=3.11 |
license | None |
keywords |
ast
code-manipulation
nix
parsing
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# 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](https://github.com/Mic92/nix-update) rely on
[simple string replacement](https://github.com/Mic92/nix-update/blob/fbb35af0ed032ab634c7ef9018320d2370ecfeb1/nix_update/update.py#L26)
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](https://tree-sitter.github.io/tree-sitter/)
, a multilingual concrete-syntax AST, and its Nix grammar [tree-sitter-nix](https://github.com/nix-community/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
```shell
nima set -f package.nix version '"1.2.3"'
```
Set a boolean value
```shell
nima set -f package.nix doCheck true
```
Remove an attribute
```shell
nima rm -f package.nix doCheck
```
Test/validate that a Nix file can be parsed
```shell
nima test -f package.nix
```
Raw data
{
"_id": null,
"home_page": null,
"name": "nix-manipulator",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.11",
"maintainer_email": null,
"keywords": "ast, code-manipulation, nix, parsing",
"author": null,
"author_email": "Hugo Herter <git@hugoherter.com>",
"download_url": "https://files.pythonhosted.org/packages/28/b4/de70d2e9ac9c7b8b38c1bcb9df5feb2e6c9532d6cd16bbd84b620f9f0285/nix_manipulator-0.1.3.tar.gz",
"platform": null,
"description": "# Nix-manipulator (Nima)\n\nA Python library and tools for parsing, manipulating, and reconstructing Nix source code.\n\n## Overview\n\nStarted during SaltSprint 2025, Nix-manipulator aims to fill the absence of tools for easily\nupdating and editing Nix code. \nPopular tools such as [nix-update](https://github.com/Mic92/nix-update) rely on \n[simple string replacement](https://github.com/Mic92/nix-update/blob/fbb35af0ed032ab634c7ef9018320d2370ecfeb1/nix_update/update.py#L26)\nor regular expressions for updating Nix code.\n\n## Features and Goals\n\n- **Ease of use** - Simple CLI and API for common operations.\n- **High-level abstractions** make manipulating expressions easy.\n- **Preserving formatting and comments** in code that respects RFC-166.\n\n## Non-goals\n\n- Preserving eccentric formatting that does not respect RFC-166 and would add unnecessary complexity.\n\n## Targeted applications\n\n- Updating values in Nix code by hand, scripts, pipelines, and frameworks.\n- Writing refactoring tools.\n- Interactive modifications from a REPL.\n\n## Foundations\n\nNix-manipulator leverages [tree-sitter](https://tree-sitter.github.io/tree-sitter/)\n, a multilingual concrete-syntax AST, and its Nix grammar [tree-sitter-nix](https://github.com/nix-community/tree-sitter-nix).\n\n## Project Status\n\nThe project is still in early-stage:\n\n- Not all Nix syntax is supported yet\n- Test-driven approach prevents regressions\n- CLI and API are still evolving and subject to change\n- 28991 / 39573 (73.26%) Nix files from nixpkgs could be parsed and reproduced\n\n## Target Audience\n\nIntermediate Nix users and developers working with Nix code manipulation.\n\n## CLI Usage\n\nNix-manipulator provides a command-line interface for common operations:\n\nSet a value in a Nix file\n```shell\nnima set -f package.nix version '\"1.2.3\"'\n```\n\nSet a boolean value\n```shell\nnima set -f package.nix doCheck true\n```\n\nRemove an attribute\n```shell\nnima rm -f package.nix doCheck\n```\n\nTest/validate that a Nix file can be parsed\n```shell\nnima test -f package.nix\n```",
"bugtrack_url": null,
"license": null,
"summary": "A Python library for parsing, manipulating, and reconstructing Nix source code with high-level abstractions while preserving formatting and comments in RFC-formatted code.",
"version": "0.1.3",
"project_urls": {
"Homepage": "https://codeberg.org/hoh/nix-manipulator",
"Source": "https://codeberg.org/hoh/nix-manipulator",
"Tracker": "https://codeberg.org/hoh/nix-manipulator/issues"
},
"split_keywords": [
"ast",
" code-manipulation",
" nix",
" parsing"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "d9b42aca65a41b5b1c44c8488463307587d26b371b062b7048f9b1fe2c796008",
"md5": "2c38aaf9726424a1b04d89b18cdf2d0f",
"sha256": "de7fade972daaf10cf2282397b03c9f6bdd144b2ffe959c93c99636e2a864153"
},
"downloads": -1,
"filename": "nix_manipulator-0.1.3-py3-none-any.whl",
"has_sig": false,
"md5_digest": "2c38aaf9726424a1b04d89b18cdf2d0f",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.11",
"size": 45872,
"upload_time": "2025-09-06T12:35:15",
"upload_time_iso_8601": "2025-09-06T12:35:15.074218Z",
"url": "https://files.pythonhosted.org/packages/d9/b4/2aca65a41b5b1c44c8488463307587d26b371b062b7048f9b1fe2c796008/nix_manipulator-0.1.3-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "28b4de70d2e9ac9c7b8b38c1bcb9df5feb2e6c9532d6cd16bbd84b620f9f0285",
"md5": "7a8b5a2d781fa45901778f2ff3061db7",
"sha256": "dd2291fc6f1150437ec34dfcba16ed971bdb116537c13827f6e6d99a802fcde8"
},
"downloads": -1,
"filename": "nix_manipulator-0.1.3.tar.gz",
"has_sig": false,
"md5_digest": "7a8b5a2d781fa45901778f2ff3061db7",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.11",
"size": 28524,
"upload_time": "2025-09-06T12:35:16",
"upload_time_iso_8601": "2025-09-06T12:35:16.672865Z",
"url": "https://files.pythonhosted.org/packages/28/b4/de70d2e9ac9c7b8b38c1bcb9df5feb2e6c9532d6cd16bbd84b620f9f0285/nix_manipulator-0.1.3.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-09-06 12:35:16",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": true,
"codeberg_user": "hoh",
"codeberg_project": "nix-manipulator",
"lcname": "nix-manipulator"
}