Expand description
Built-in binary cache server and push pipeline for sui.
Replaces Attic, Cachix, and nix-serve with a single integrated component. Implements the standard Nix binary cache HTTP protocol (narinfo + NAR).
§Architecture
sui_castore— pluggable storage backends (shared with sui-registry); re-exported from here for backward compatibility.server— axum HTTP server implementing the cache protocolsigning— ed25519 key management and narinfo signingpush— pipeline to push store paths to the cachegc— garbage collection of unreferenced cache entriesconfig— cache configuration types (CacheConfig; BackendConfig is in sui-castore)
Re-exports§
pub use config::CACHE_TIER_ENV;pub use config::CacheConfig;pub use gc::GcResult;pub use push::LevelOutOfRange;pub use push::NarCodec;pub use push::PushResult;pub use push::XzLevel;pub use push::ZstdLevel;pub use server::AppState;pub use server::build_router;pub use server::serve;pub use signing::CacheSigner;pub use signing::verify_narinfo_signature;
Modules§
- config
- Cache configuration types.
- gc
- Garbage collection for the binary cache.
- push
- Push pipeline — build output to NAR to sign to upload.
- server
- Axum HTTP server implementing the Nix binary cache protocol.
- signing
- Ed25519 signing for narinfo metadata.
Structs§
- Bytes
NarSource - A
NarSourceover bytes already in memory. - File
NarSource - A
NarSourceover a file on disk. - Local
Storage - Filesystem-backed binary cache storage.
- MemNar
RefIndex - In-memory
NarRefIndex— the reference semantics, and what every test double uses. - NarRef
Key - The typed key of one reverse edge: “
hash’s narinfo advertisesnar_path”. - NarRef
Scan - The typed key prefix enumerating every edge into one NAR.
- PgStorage
Backend - L2 durable cache tier: content-addressed key → value over Postgres, shared across pods, survives a roll.
- Redis
Backend - L1 hot cache: content-addressed key → value, sub-ms hits, TTL/eviction-aware.
- S3Storage
- S3-compatible object storage backend.
- Spooled
NarSource - A
NarSourceover a spool file, deleted when the source is dropped. - Storage
Index - Ephemeral metadata index backed by redb.
- Tiered
Backend - Three-tier read-through / write-through cache resolver.
Enums§
- Backend
Config - Storage backend selection.
- Cache
Error CacheErroris nowsui_castore::StoreError(same variants, same derives). This type alias preserves every existingsui_cache::CacheErroruse site. Error type for content-addressed store operations.- Expand
EnvError - A
${VAR}token referenced an environment variable that is not set. - NarResidency
- What a backend’s NAR path costs in resident memory.
- PgTable
- The three logical tables the cache tier keeps: narinfo text, NAR blobs, and the reverse edges between them.
- Tiered
Tier - The honest self-description of what
TieredBackendhas been proven against — asserted by the honest gate so a claim cannot be silently rounded up. - Write
Policy - How a
putpropagates across the tiers. See the module docs for the full contract; every policy persists both durable tiers before returning.
Constants§
- DEFAULT_
INGEST_ MEMORY_ CAP - Default cap for the in-memory ingest fallback — see
spool_or_buffer. - NAR_
CHUNK_ BYTES - The bounded chunk size every streaming NAR path moves bytes in.
- NAR_
REF_ PREFIX - Key-space prefix owning every reverse edge.
- TIERED_
BACKEND_ TIER - The shipped tier of
TieredBackend. Asserted by the honest gate; bumping it toLiveClusterProvenwithout a live integration test is a build-failing round-up.
Traits§
- NarRef
Index - The reverse index of a single
StorageBackend. - NarSource
- A re-openable NAR byte source.
- PgCache
Conn - The minimal typed Postgres row-verb surface
PgStorageBackenddepends on. - Redis
Conn - The minimal async redis verb surface
RedisBackenddepends on. - Storage
Backend - Abstraction over binary cache storage.
Functions§
- advertised_
nar_ url - The NAR path a stored narinfo advertises, if it advertises an addressable one.
- advertised_
url_ line - The raw
URL:field of a narinfo, unjudged. - build_
backend - Config-select factory: build the concrete
StorageBackendaBackendConfignames. - bytes_
stream - Yield in-memory bytes as bounded chunks (zero-copy slices of one allocation).
- collect_
nar - Drain a
NarStreaminto one buffer. - empty_
stream - A stream that yields nothing.
- expand_
env_ vars - Expand
${VAR}tokens intextagainst the process environment. - file_
stream - Read an open file as bounded chunks. O(chunk) resident.
- is_
addressable_ nar_ path - Whether a narinfo’s
URL:is a NAR path this store can safely address. - is_
servable_ narinfo - Is this narinfo text usable by a Nix client at all?
- referrer_
of - Recover the referring store-path hash from a scanned edge key.
- spool_
or_ buffer - Turn a one-shot byte stream into a re-openable
NarSource, bounded either way. - whole_
value_ stream - A stream that yields exactly one chunk — the whole value.
Type Aliases§
- NarStream
- A NAR byte stream — bounded chunks, consumed exactly once.