Running the Server
static-nix-cache can also run as a standalone HTTP server, implementing the full Nix binary cache API.
Starting the Server
npm install
npm start # listens on port 8080 by default
The server exposes the standard Nix binary cache HTTP endpoints:
GET /nix-cache-info— cache metadataGET /:hash.narinfo— store path metadataGET /nar/:filename— NAR file downloadPUT /:hash.narinfo/PUT /nar/:filename— upload endpoints
Push Store Paths
Use nix copy to push store paths to the running server:
nix copy --to 'http://localhost:8080?compression=none' /nix/store/<hash>-<name>
Authentication
Set UPLOAD_SECRET to require a bearer token for PUT (upload) requests:
UPLOAD_SECRET=mysecret npm start
Then push with:
nix copy --to 'http://localhost:8080?secret=mysecret&compression=none' /nix/store/<hash>-<name>
Running Tests
npm test