Nix-index database for nixwrap
Project description
nixwrap
Run Nix packages from Python without Nix installed.
Overview
nixwrap provides two ways to run Nix-built binaries:
- Direct CLI: Run any package from nixpkgs instantly
- Python packages: Install tools via pip/uv from a PEP 503 index
Both methods fetch binaries from the Nix binary cache, patch them for relocation, and run them using a bundled dynamic linker.
Quick Start
CLI (Recommended)
# Install nixwrap
pip install nixwrap
# Run any nixpkgs package directly
nixwrap ripgrep --version
nixwrap jq --help
nixwrap fd --version
# Or use uvx for one-off execution
uvx nixwrap bat README.md
Python Package Index
# One-off execution with uvx
uvx --index-url https://elohmeier.github.io/nixwrap fd --version
# Or via pipx
uvx --with pip pipx run --index-url https://elohmeier.github.io/nixwrap fd --version
# Install a tool permanently
uv tool install --index-url https://elohmeier.github.io/nixwrap ripgrep
# Use the tool
rg --version
How It Works
Both modes share the same core process:
- Package Discovery: Queries the nix-index-database to find packages and their binaries
- Closure Computation: Fetches narinfo files to compute the full dependency closure
- Binary Fetching: Downloads and extracts NAR archives from the Nix binary cache
- Patching: Uses patchelf to fix binaries with hardcoded
/nix/storepaths - Execution: Runs binaries via a bundled
ld-linuxwith the correct library path
CLI Mode
When using nixwrap <package>, binaries are cached locally:
~/.cache/nixwrap/
nix/store/ # Extracted packages and dependencies
packages/ # Package metadata cache (speeds up repeated runs)
The first run downloads and patches the binary. Subsequent runs use the cached version.
Index Mode
When installing from the PEP 503 index, the build backend:
- Fetches all dependencies at wheel build time
- Patches binaries and bundles them directly into the wheel
- Installs the wheel with all binaries as package data
This results in a self-contained Python package with no external cache.
Repository Structure
nixwrap/
pyproject.toml # Main package configuration
src/nixwrap/
__init__.py
backend.py # PEP 517 build backend for wheels
cli.py # CLI entry point (nixwrap command)
index.py # nix-index-database parser
patcher.py # ELF patching with patchelf
nixwrap-index/ # Separate package containing nix-index data
pyproject.toml
src/nixwrap_index/
__init__.py
data/ # Index files (downloaded in CI)
tools/
generate_stubs.py # Generates stub sdists for PEP 503 index
.github/workflows/
publish-pages.yml # Publishes stubs to GitHub Pages
publish-pypi.yml # Publishes nixwrap to PyPI
publish-pypi-index.yml # Publishes nixwrap-index to PyPI
Requirements
- Python 3.14+ (for
compression.zstdstdlib module) - Linux x86_64 or aarch64
Development
# Clone and setup
git clone https://github.com/elohmeier/nixwrap.git
cd nixwrap
uv sync
# Run the CLI locally
uv run nixwrap ripgrep --version
# Build wheels locally
uv build
Limitations
-
Hardcoded runtime paths: Some packages have
/nix/store/...paths compiled into the binary for runtime files (config, data, plugins). These paths can't be patched with patchelf. Examples:neovim-unwrapped: Works for--versionbut fails at runtime because it can't find Lua modules and syntax files at the hardcoded paths.- Simple CLI tools like
ripgrep,fd,jq,batwork fine since they don't depend on external runtime files.
-
Wrapper scripts: Packages that use shell wrapper scripts (like
neovim,python) won't work because they have hardcoded paths in bash scripts, not ELF binaries. -
Linux only: Currently only supports Linux (x86_64 and aarch64).
-
Python 3.14+: Requires Python 3.14 for the stdlib zstd module.
License
MIT
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 Distributions
Built Distributions
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 nixwrap_index-2026.2.8-py3-none-manylinux_2_17_x86_64.whl.
File metadata
- Download URL: nixwrap_index-2026.2.8-py3-none-manylinux_2_17_x86_64.whl
- Upload date:
- Size: 92.9 MB
- Tags: Python 3, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
345f0951fb3123ee5643f1c648dd965ce52294b9d6c4cd9a6b71aaa48d04990f
|
|
| MD5 |
011b80d04588cd08c4476df1ea04caf7
|
|
| BLAKE2b-256 |
ae795e33b13b74f64baaa24cb98e5c70bbc6798b7a5872618773bc416a0598d5
|
Provenance
The following attestation bundles were made for nixwrap_index-2026.2.8-py3-none-manylinux_2_17_x86_64.whl:
Publisher:
publish-pypi-index.yml on elohmeier/nixwrap
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
nixwrap_index-2026.2.8-py3-none-manylinux_2_17_x86_64.whl -
Subject digest:
345f0951fb3123ee5643f1c648dd965ce52294b9d6c4cd9a6b71aaa48d04990f - Sigstore transparency entry: 927269413
- Sigstore integration time:
-
Permalink:
elohmeier/nixwrap@5723f56e6a8f853bd0a382a56c250251b45b7a3e -
Branch / Tag:
refs/heads/main - Owner: https://github.com/elohmeier
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi-index.yml@5723f56e6a8f853bd0a382a56c250251b45b7a3e -
Trigger Event:
schedule
-
Statement type:
File details
Details for the file nixwrap_index-2026.2.8-py3-none-manylinux_2_17_aarch64.whl.
File metadata
- Download URL: nixwrap_index-2026.2.8-py3-none-manylinux_2_17_aarch64.whl
- Upload date:
- Size: 86.4 MB
- Tags: Python 3, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4fc267d01ff20916e5e7e3c1cc5b6861b008118a600e3e8f80a9604df8ba767a
|
|
| MD5 |
33c3f177911409545f59def5d14275fb
|
|
| BLAKE2b-256 |
5b441062fe765999dd6d6d585982cae00be583bfc3cf2c41ce485d9bf5ce4942
|
Provenance
The following attestation bundles were made for nixwrap_index-2026.2.8-py3-none-manylinux_2_17_aarch64.whl:
Publisher:
publish-pypi-index.yml on elohmeier/nixwrap
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
nixwrap_index-2026.2.8-py3-none-manylinux_2_17_aarch64.whl -
Subject digest:
4fc267d01ff20916e5e7e3c1cc5b6861b008118a600e3e8f80a9604df8ba767a - Sigstore transparency entry: 927269411
- Sigstore integration time:
-
Permalink:
elohmeier/nixwrap@5723f56e6a8f853bd0a382a56c250251b45b7a3e -
Branch / Tag:
refs/heads/main - Owner: https://github.com/elohmeier
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi-index.yml@5723f56e6a8f853bd0a382a56c250251b45b7a3e -
Trigger Event:
schedule
-
Statement type: