How kalbasit/ncps works
ncps is a Nix binary-cache proxy: Nix clients request metadata and store files, which the server serves from local cache or retrieves from configured upstream caches and retains for reuse. The README documents multiple upstreams, local/S3 storage, database choices, chunked CDC, signing, Redis-backed high availability, and observability. The graph reflects those documented capabilities and the sampled HTTP, application-entry, and database code; internal cache-to-backend wiring is not fully visible in the excerpts.
Main entry points: cache.go Cache coordinator · server.go HTTP API · root.go CLI application · serve.go Serve command
Components 24
Application
- Process entry
main.go - CLI application
pkg/ncps/root.go - Serve command
pkg/ncps/serve.go
Cache API
- HTTP API
pkg/server/server.go
Cache processing
- Cache coordinator
pkg/cache/cache.go - Upstream caches
pkg/cache/upstream/cache.go - NAR processing
pkg/nar/reader.go - Chunking
pkg/chunker/chunker.go - Cache policy
pkg/cache/queries.go - NAR metadata
pkg/narinfo/hash.go
Persistence
- Database client
pkg/database/client.go - Cache database
ent/schema/narinfo.go - Storage interface
pkg/storage/store.go - Local storage
pkg/storage/local/local.go - S3 storage
pkg/storage/s3/s3.go - Redis locking
pkg/lock/redis/locker.go
Operations
- Migration commands
pkg/ncps/migrate.go - Cache verification
pkg/ncps/fsck.go - Metrics and tracing
pkg/otel/otel.go
Other components
- Nix client
- Upstream cache
- Local filesystem
- S3-compatible store
- Redis
Connections 23
- Nix client → HTTP API: HTTP requests
- Process entry → CLI application: starts
- CLI application → Serve command: dispatches
- Serve command → HTTP API: starts server
- HTTP API → Cache coordinator: handles cache requests
- Cache coordinator → Upstream caches: fetches misses
- Upstream caches → Upstream cache: requests NARs
- Cache coordinator → Database client: reads and writes metadata
- Database client → Cache database: queries and persists
- Cache coordinator → Storage interface: stores and reads NARs
- Storage interface → Local storage: selects backend
- Storage interface → S3 storage: selects backend
- Local storage → Local filesystem: reads and writes
- S3 storage → S3-compatible store: reads and writes
- Cache coordinator → NAR processing: processes NARs
- Cache coordinator → Chunking: chunks content
- Cache coordinator → Cache policy: applies cache policy
- HTTP API → NAR metadata: serves cache metadata
- Serve command → Redis locking: configures distributed locking
- Redis locking → Redis: acquires locks
- CLI application → Migration commands: dispatches migrations
- CLI application → Cache verification: dispatches verification
- HTTP API → Metrics and tracing: records telemetry