Python bindings for evaluating and round‑tripping Nix expressions into Python Values, powered by [snix_eval] and [PyO3].
- 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.
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.
Install from PyPI:
pip install nixevalOr test it from source:
git clone https://github.com/rucadi/py-nixeval.git
cd py-nixeval
nix-shell
maturin develop --releaseimport 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'}