Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Python bindings for evaluating and round‑tripping Nix expressions, powered by [snix_eval] and [PyO3].

License

Notifications You must be signed in to change notification settings

Rucadi/py-nixeval

Repository files navigation

py-nixeval

Python bindings for evaluating and round‑tripping Nix expressions into Python Values, powered by [snix_eval] and [PyO3].

Features

  • Parse Nix expressions into native Python objects.
  • Serialize Python objects to JSON then convert back into Nix values using
  • Windows/Linux/Mac support Nix is usually not seen in windows, but thanks to tvix/snix projects now you can use it on windows as well as common platforms.
  • Seamless round‑trip between Nix and Python data structures.

Limitations

The implementation internally relies on the python json module and on nix features builtins.toJSON and builtins.fromJSON, this means that an unevaluated lambda in the result will not work.

Installation

Install from PyPI:

pip install nixeval

Or test it from source:

git clone https://github.com/rucadi/py-nixeval.git
cd py-nixeval
nix-shell
maturin develop --release

Quickstart

import nixeval

# Parse a Nix list into Python
data = nixeval.loads('[ 1 2 3 ]')
assert data == [1,2,3]

# Parse a Nix attribute set into Python dict
config = nixeval.loads('{ foo = "bar"; baz = [ true false ]; }')
print(config)
# {'baz': [True, False], 'foo': 'bar'}

About

Python bindings for evaluating and round‑tripping Nix expressions, powered by [snix_eval] and [PyO3].

Resources

License

Stars

Watchers

Forks

Packages

No packages published