mnix: Nix binary-cache client PoC in MoonBit (install hello from cache.nixos.org) #1

Merged
nandi merged 5 commits from feat/mnix-binary-cache-client into main 2026-11-24 22:12:02 +00:00
Owner

Summary

Proof-of-concept mnix CLI implementing the binary-cache side of Nix in MoonBit (native backend): mnix install hello fetches hello and its closure from cache.nixos.org, verifies it, unpacks it and mnix run hello prints Hello, world!.

What works (verified for real against cache.nixos.org / hydra.nixos.org, x86_64-linux)

  • store path model + nixbase32, narinfo parsing, ed25519 signature verification (cache.nixos.org-1), closure over References, xz + zstd NAR download, FileHash/NarHash/size verification, NAR parse (+writer), atomic unpack, profile (install/list/remove/env/run), search.
  • hello (5-path closure) and ripgrep installed and run, both with a user-writable store (via an unprivileged user+mount namespace in mnix run) and with native /nix/store.
  • moon check --deny-warn, moon test --deny-warn (35 tests), moon fmt clean. Tests include a real signed narinfo, real xz/zstd vectors, NAR round trips, real symlink/exec-bit unpack.

Design decisions / limitations (details in README)

  • Name resolution: Hydra JSON API (/job/<project>/<jobset>/<attr>.<system>/latest-finished) for exact per-platform paths; store-paths.xz only for search because it mixes platforms. Not pinned to the channel revision.
  • Binaries hardcode /nix/store; no relocation. Either use --store /nix/store or mnix run (namespace wrapper, needs unprivileged userns).
  • In-memory NARs (<2 GiB), sequential downloads, no store DB/GC, out output only, bin/ links only.
  • Stretch goal (Nix expression evaluator) not implemented.
  • Reused mooncakes: moonbitlang/async, moonbitlang/x (sha256), hustcer/ed25519, lin2077-zeming/moonxz, gaato/zstd.

🤖 Generated with Claude Code

## Summary Proof-of-concept `mnix` CLI implementing the binary-cache side of Nix in MoonBit (native backend): `mnix install hello` fetches `hello` and its closure from cache.nixos.org, verifies it, unpacks it and `mnix run hello` prints `Hello, world!`. ## What works (verified for real against cache.nixos.org / hydra.nixos.org, x86_64-linux) - store path model + nixbase32, narinfo parsing, ed25519 signature verification (`cache.nixos.org-1`), closure over References, xz + zstd NAR download, FileHash/NarHash/size verification, NAR parse (+writer), atomic unpack, profile (`install`/`list`/`remove`/`env`/`run`), `search`. - `hello` (5-path closure) and `ripgrep` installed and run, both with a user-writable store (via an unprivileged user+mount namespace in `mnix run`) and with native `/nix/store`. - `moon check --deny-warn`, `moon test --deny-warn` (35 tests), `moon fmt` clean. Tests include a real signed narinfo, real xz/zstd vectors, NAR round trips, real symlink/exec-bit unpack. ## Design decisions / limitations (details in README) - Name resolution: Hydra JSON API (`/job/<project>/<jobset>/<attr>.<system>/latest-finished`) for exact per-platform paths; `store-paths.xz` only for `search` because it mixes platforms. Not pinned to the channel revision. - Binaries hardcode `/nix/store`; no relocation. Either use `--store /nix/store` or `mnix run` (namespace wrapper, needs unprivileged userns). - In-memory NARs (<2 GiB), sequential downloads, no store DB/GC, `out` output only, bin/ links only. - Stretch goal (Nix expression evaluator) not implemented. - Reused mooncakes: moonbitlang/async, moonbitlang/x (sha256), hustcer/ed25519, lin2077-zeming/moonxz, gaato/zstd. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
nandi added 4 commits 2026-11-24 22:09:57 +00:00
Store path model + nixbase32, narinfo parser, ed25519 signature
verification, NAR reader/writer, closure computation, xz/zstd NAR fetch
with hash verification, atomic store unpack, profile management, Hydra-based
name resolution, and the mnix CLI. README documents usage, the /nix/store
limitation, and what a fuller implementation needs.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
nandi added 1 commit 2026-11-24 22:11:13 +00:00
nandi merged commit fa70164336 into main 2026-11-24 22:12:02 +00:00
Sign in to join this conversation.
No Reviewers
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: experiments/moon-nix#1