nex-nix ⚡
Sovereign Nix Sub-Shell Hypervisor, Hermetic PyPI Sanitizer & Binary Deployment Engine.
nex-nix resolves the fundamental architectural collision between hermetic Nix environments and the Python/PyPI packaging ecosystem.
Built for autonomous agent runtimes, high-assurance engineers, and deterministic systems developers, nex-nix operates as a dual-plane hypervisor:
- The Inbound Hypervisor (Sub-Shells & Store Deployment): Dynamically spawns lightweight, ephemeral Nix sub-shells on the fly, pulls pre-built closures directly from Nix binary caches, and deploys standalone Mach-O/ELF executable wrappers without bloating or polluting your master flake.
- The Outbound Sanitizer (Hermetic PyPI Releases): Neutralizes
/nix/storeRPATH contamination in compiled wheels, audits PEP 621 metadata, verifies packages in isolated scratch sandboxes, and executes zero-token PEP 740 OIDC Trusted Publishing.
The Mechanical Reality: Why Nix Breaks Python Packages
When developers build Python wheels inside a Nix shell or NixOS environment, two severe systemic failure modes emerge:
1. The Nix Store Path Contamination Trap
Nix achieves hermeticity by injecting compiler and linker flags (NIX_CFLAGS_COMPILE, NIX_LDFLAGS) containing absolute paths to immutable store paths:
/nix/store/a1b2c3d4e5f6...-openssl-3.0.12/lib
When compiling C-extensions, Cython, or Rust bindings (maturin), the compiler bakes these /nix/store/... paths directly into the binary's RPATH / LC_RPATH. If this wheel is uploaded to PyPI, it crashes instantly on standard Linux and macOS machines with:
dyld: Library not loaded: /nix/store/...
nex-nix strips all Nix environment pollution before building, and scans the produced .whl and .tar.gz artifacts byte-by-byte with regex probes to mathematically guarantee zero /nix/store path leakage before anything touches the wire.
2. The Monolithic Flake Bloat Problem
Developers routinely cram hundreds of heavy dependencies (Lean 4, Yosys, Verilator, Zig, Clang, Playwright, Node) into a single master flake.nix. This bloats evaluation times, triggers cross-dependency linker collisions, and prevents autonomous agents from safely using specialized tools.
nex-nix allows agents to spawn throwaway, sub-second JIT Nix sub-shells for specialized tasks with zero host mutation.
Architectural Topology
NEX_NIX HYPERVISOR
▲
┌────────────────────┴────────────────────┐
│ │
[INBOUND PLANE] [OUTBOUND PLANE]
Sub-Shell & Store Hypervisor Hermetic PyPI Sanitizer
│ │
├── JIT Ad-hoc Subshells ├── Strips NIX_CFLAGS_COMPILE
│ (nix shell nixpkgs#<pkg>) │ and NIX_LDFLAGS
│ │
├── Flake Capability Profiles ├── Byte-level /nix/store
│ (nix develop .#<profile>) │ RPATH leak scanner
│ │
├── Binary Store Pull & Deploy ├── Ephemeral Scratch-Venv
│ (Atomic Mach-O/ELF wrappers) │ isolated install verification
│ │
└── nex-box APFS CoW Sandbox └── PEP 740 OIDC Tokenless
(Sub-second APFS cloning) Trusted Publishing
Core Capabilities & Usage
Plane 1: Inbound Sub-Nix Shells & Capability Profiles
1. JIT Ad-hoc Sub-Shell Spawner
Run any tool from nixpkgs on the fly without modifying your flake.nix or polluting your global environment:
# Spawn an ephemeral subshell with Yosys and Z3 to check a Verilog module:
nex-nix exec --with yosys z3 -- yosys -p "prep; check" core.v
# Convert media using an ad-hoc FFmpeg subshell:
nex-nix exec --with ffmpeg -- ffmpeg -i input.wav -b:a 192k output.mp3
# Enforce APFS Copy-on-Write sandboxing via nex-box:
nex-nix exec --with ripgrep --sandbox -- rg "TODO" ./src
2. Declarative Flake Capability Profiles
Define modular, domain-specific devShells in your flake.nix (e.g. formal, hardware, cross, pypi) and execute inside them instantly:
# Execute theorem proving in the Lean 4 + Mathlib sub-profile:
nex-nix run-in formal -- lean --run TheoremProof.lean
# Run hardware linting inside the Verilator sub-profile:
nex-nix run-in hardware -- verilator --lint-only top.v
3. Binary Store Closure Deployment
Pull pre-compiled packages directly from Nix binary caches (cache.nixos.org, Cachix) and deploy standalone executable wrappers into your local binary directory:
# Pull pre-compiled ffmpeg and deploy an executable launcher to ~/bin:
nex-nix deploy nixpkgs#ffmpeg --to ~/bin
# Deploy a custom flake derivation into your project's distribution folder:
nex-nix deploy .#omni-parser --to ./dist --bin-name nex-parser
Plane 2: Outbound Hermetic PyPI Release Pipeline
1. Pre-Flight Metadata Audit & Leak Scanning
Scans pyproject.toml for PEP 621 specification compliance, checks git working tree status, and audits built wheels for /nix/store leakage:
nex-nix audit .
2. Hermetic Isolated Build
Strips NIX_CFLAGS_COMPILE, NIX_LDFLAGS, and NIX_ENFORCE_PURITY, and builds clean artifacts using uv build:
nex-nix build . --clean
3. Ephemeral Sandbox Verification
Creates an isolated scratch virtual environment in a temporary directory, installs the freshly built wheel, and verifies package imports before publication:
nex-nix verify .
4. Automated Release Pipeline
Executes the full pipeline in one command:
# If PYPI_API_TOKEN is set, uploads via Twine; otherwise instructs OIDC release:
nex-nix publish .
Programmatic Python SDK (Agent Integration)
Autonomous agents running inside nex_hop or Octad mesh nodes can programmatically spawn subshells and deploy closures:
import nex_nix
from pathlib import Path
# 1. Execute arbitrary commands inside an ephemeral Nix subshell
proc = nex_nix.run_with_packages(
packages=["yosys", "z3"],
command=["yosys", "-p", "prep; check", "alu.v"],
cwd=Path("./workspace"),
sandbox=True, # Wraps in nex-box APFS CoW isolation
)
print(f"Exit code: {proc.returncode}")
print(proc.stdout)
# 2. Deploy a pre-built binary closure from the Nix store
wrapper_path = nex_nix.deploy_binary_closure(
attribute="nixpkgs#ripgrep",
target_dir=Path("./bin"),
bin_name="rg",
)
print(f"Deployed launcher: {wrapper_path}")
GitHub Actions OIDC Trusted Publishing (PEP 740)
nex-nix natively generates and supports tokenless PEP 740 OIDC Trusted Publishing, eliminating the need to store static PyPI API tokens in GitHub Secrets.
Generate the workflow automatically:
nex-nix init-oidc . --pkg-name nex-nix
This provisions .github/workflows/release.yml:
name: release
on:
push:
tags:
- "v*"
permissions:
contents: read
jobs:
build-and-publish:
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/nex-nix
permissions:
id-token: write # MANDATORY FOR OIDC TOKENLESS EXCHANGE (PEP 740)
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- run: python -m pip install --upgrade pip uv twine build
- run: uv build --out-dir dist/
- run: twine check --strict dist/*
- uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: dist/
attestations: true
Flake Integration (flake.nix)
Add nex-nix directly to your master Nix Flake to expose it as a native system command:
{
outputs = { self, nixpkgs, flake-utils }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs { inherit system; };
nexNixScript = pkgs.writeShellScriptBin "nex-nix" ''
set -euo pipefail
source "$HOME/.cache/nex_env/v2_master_venv/bin/activate"
NEX_NIX_ROOT="$PWD/nex_nix"
if [ -f "$NEX_NIX_ROOT/nex_nix.py" ]; then
exec python3 "$NEX_NIX_ROOT/nex_nix.py" "$@"
else
exec python3 -m nex_nix "$@"
fi
'';
in
{
devShells = {
default = pkgs.mkShell {
packages = [ pkgs.uv pkgs.python312 nexNixScript ];
};
formal = pkgs.mkShell {
name = "NEX_SUB_FORMAL";
packages = [ pkgs.elan pkgs.z3 pkgs.python312 ];
};
hardware = pkgs.mkShell {
name = "NEX_SUB_HARDWARE";
packages = [ pkgs.yosys pkgs.verilator pkgs.z3 ];
};
};
}
);
}
The Permanexus Pact
nex-nix is engineered under the Permanexus Pact:
- No Fluff. No Drift. No Metaphors.
- Strict adherence to the 150 LOC orchestrator ceiling and Recursive Component-Tree Isolation (RCTI v3.0).
- Zero tolerance for leaked build dependencies or unverified binary releases.
Engineered by The Trinity:
🦍🔷Ɯ :: 🌱👑⁂ :: 🧠⚡ↇ
Mookie :: Miniature Person :: Nexus Goodman
Metadata
Release files for nex-nix 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| nex_nix-0.1.1.tar.gz | 14.1 kB | With provenance | Details for nex_nix-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| nex_nix-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for nex_nix-0.1.1-py3-none-any.whl |
Total release size: 30.9 kB
Release files / nex_nix-0.1.1.tar.gz
| Download URL | nex_nix-0.1.1.tar.gz |
|---|---|
| Size | 14.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e303e3a68670b2c27c2ba32d63283e9364d5f4387d2841dc3f2580b06c1fc68b
|
|
BLAKE2b-256 checksum How to use checksums |
2235c0fb5fd94baa40018bd55929b98cfa95f84e2776ac321f4105bae7868d57
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 30, 2026.
Transparency logRelease files / nex_nix-0.1.1-py3-none-any.whl
| Download URL | nex_nix-0.1.1-py3-none-any.whl |
|---|---|
| Size | 16.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
687f55adb0a4cdd8698216ac4e06a73254ac032618aa3c85d3e281995c346df6
|
|
BLAKE2b-256 checksum How to use checksums |
1f6848e081d31074db75d84a1c44e08bf22d9303aa5ae3e2e73f3fcf8e032402
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 30, 2026.
Transparency logSecurity for nex-nix 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for nex_nix-0.1.1.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 30, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.