Skip to content

feat(DEN-1418): add reproducible Zed-to-Nix fixed-output bridge - #36

Merged
ORESoftware merged 40 commits into
mainfrom
agent/den-1411-nix-bridge
Aug 3, 2026
Merged

feat(DEN-1418): add reproducible Zed-to-Nix fixed-output bridge#36
ORESoftware merged 40 commits into
mainfrom
agent/den-1411-nix-bridge

Conversation

@ORESoftware

@ORESoftwareORESoftware commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Linear and RFC

Summary

Adds a reusable Nix bridge for the independent zed-pkg package manager. This has no relationship to the Zed text editor.

The bridge keeps one dependency-resolution authority:

  1. .zpkg.lock remains the canonical resolved graph and exact provenance input.
  2. zed install --frozen --install-mode copy verifies and materializes that graph while the bridge proves lock and manifest bytes did not change.
  3. Nix recursively hashes and verifies the complete materialized output.
  4. A normal stdenv derivation consumes the verified materialization offline.

What ships

  • nix/zed-package.nix
    • fetchZedDeps: recursive fixed-output derivation, isolated Zed/XDG homes, frozen copy install, dependency build hooks disabled, public/credential-free registry boundary, exact immutable file-registry inputs, byte-for-byte frozen-input checks, and fail-closed symlink/transaction checks.
    • An immutable registryPath is an explicit Nix input and may be imported with builtins.storePath, preserving the exact file:///nix/store/... identity frozen into the input lock.
    • Raw lock, manifest, and registry URL strings are not copied into the FOD output. Nix correctly rejects fixed outputs that reference another store object, and registry strings may contain credentials.
    • The output instead retains exact lock/manifest SHA-256 values plus deterministic zed.nix-lock-summary/v1 inventory metadata containing artifact identity and normalized source kind, never source literal.
    • mkZedPackage: overlays the verified tree into an ordinary network-isolated derivation while preserving the caller's stdenv surface and making only the private unpacked build tree writable.
  • Frozen-install transaction hardening
    • the lockfile is checkpointed atomically while its source bytes remain visible;
    • frozen install can commit without rewriting or removing that immutable input;
    • rollback restores exact lock bytes after a failed rewrite; and
    • focused transaction tests cover both successful frozen commit and failed-rewrite restoration.
  • Core frozen-install hardening in src/ops.rs
    • frozen install is a verifier/materializer and never reserializes .zpkg.lock;
    • comments, exact source URLs, formatting, and future provenance fields remain byte-identical;
    • non-frozen resolution retains the existing deterministic lockfile write path; and
    • regression coverage exercises exact byte preservation.
  • nix/default.nix, nix/flake.nix, and nix/flake.lock library/pinning entrypoints.
    • The committed Nixpkgs revision matches the reviewed baseline used by zed-interfaces.
  • tests/nix/interop.nix, using the exact branch binary and the existing Docker copy-mode Node fixture.
    • Linux runner binaries are normalized with autoPatchelfHook inside Nix rather than depending on host /lib.
    • Existing file-registry objects are imported with builtins.storePath, preserving both exact input identity and a declared sandbox dependency.
  • Linux/macOS GitHub Actions coverage that:
    • loads Nixpkgs strictly from the committed flake lock with lock updates disabled;
    • publishes a real local Zed artifact and freezes a real .zpkg.lock;
    • asserts the fixture's dependency build hook never runs;
    • bootstraps the recursive output hash;
    • proves equivalent SHA-256 NAR output under two derivation names;
    • verifies lock/manifest digests and the source-redacted inventory;
    • proves the fixed output retains no Nix store references;
    • builds and checks a normal offline consumer derivation;
    • rejects an incorrect Nix output hash; and
    • rejects a tampered Zed artifact digest in .zpkg.lock.
  • docs/nix-interop.md and nix/README.md, including:
    • Zed-to-Nix publishing tiers;
    • the strict pinned Nix-to-Zed sealing boundary;
    • the approved future zed interop nix ... command family; and
    • the distinction among zed.nix-fetch-bridge/v1, zed.nix-lock-summary/v1, and canonical zed.nix-adapter/v1 records.

Explicit boundaries

  • This is a deterministic materialized-tree bridge, not yet the final standalone-flake exporter required by DEN-1418.
  • Nix does not re-resolve Zed semver requirements.
  • Dependency build hooks are not hidden inside the fetcher.
  • Private registry secrets are not inherited into the derivation.
  • Ordinary zed-pkg workflows still do not require Nix.
  • Arbitrary or mutable Nix expressions are not accepted as Zed imports.
  • The bridge receipt is not represented as the final canonical publication attestation.
  • CI has read-only repository permissions and does not commit or push back to the PR branch.

Validation

All final-head checks pass: Linux and macOS Nix interop, ordinary Rust CI, copy-mode OCI, manifestless and polyglot installation suites, repository hardening, formal procedures, agents policy, and pinned development-shell coverage. The PR is ready for review; it has not been merged or configured for auto-merge.

@linear-code

linear-codeBot commented Aug 3, 2026

Copy link
Copy Markdown

DEN-1411

DEN-1418

@ORESoftwareORESoftware changed the title feat(DEN-1411): add reproducible Zed-to-Nix fixed-output bridgefeat(DEN-1418): add reproducible Zed-to-Nix fixed-output bridgeAug 3, 2026
@ORESoftwareChatGPT Codex Connector

Copy link
Copy Markdown
ContributorAuthor

zed-pkg-test certification evidence

This PR's formatter-clean head 3a91d64abf1fc0bdee6eab2ff804113b1429849f has completed both stages of the zed-pkg-test procedure.

Immutable candidate smoke

  • harness PR: zed-pkg-test/zed-pkg-e2e#9
  • harness SHA: fe34a2a6b910806480aee1b3aee68d617ad0c6fe
  • run 30787069259 — passed exact-input validation, formatter/tests/release build, candidate checksum verification, all 15 pinned fixture lifecycles, and the aggregate gate

The smoke sequence first exposed the frozen .zpkg.lock deletion at 8d318ce4…, then rejected the semantic fix at 73e7d818… for formatting. The current head contains atomic lockfile checkpointing, exact-byte commit/rollback tests, and the formatting correction; fixture assertions were not weakened.

Full candidate certification

Pin-only PR: zed-pkg-test/zed-pkg-e2e#10 @ a3a62fb042e7060e27919683f8340b572b5b1a42

  • lifecycle 30787663937 — passed the complete 22-repository matrix and aggregate gate
  • browser/local-registry E2E 30787663909 — passed
  • install-boundary/Docker/OCI 30787663924 — passed

The candidate SHA is fully certified. PR #10 remains unmerged, so it has not yet promoted this SHA to the default reviewed certification baseline. Evidence is also recorded on DEN-1418 and in the Linear zed-pkg-test certification runbook.

@ORESoftwareChatGPT Codex Connector

Copy link
Copy Markdown
ContributorAuthor

Follow-up test ratchet opened: #73 (agent/den-1418-nix-evaluation-contracts). It is stacked directly on this exact green head and adds only pure nix flake check --no-build coverage for the public fetchZedDeps/mkZedPackage argument contract plus documentation. It deliberately does not alter the fixed-output implementation or duplicate this PR’s Linux/macOS sandbox canary.

Preserve the complete fixed-output Zed→Nix implementation while incorporating the independent lossless .tool-versions parser and tests from current main. The changed path sets are disjoint except for the crate export surface, where both modules remain exported.
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

@ORESoftware