Skip to main content

Configuration

static-nix-cache is configured entirely through environment variables.

Environment Variables

VariableDefaultDescription
PORT8080HTTP port to listen on
STORE_DIR/nix/storeNix store directory
CACHE_PRIORITY30Cache priority (lower = higher priority)
STORAGE_BACKENDlocallocal, s3, or github-releases
LOCAL_STORAGE_PATH./cacheRoot directory for local storage
S3_BUCKET(required for s3)S3 bucket name
S3_REGIONautoS3 region
S3_ENDPOINT(AWS default)Custom endpoint URL (e.g. Cloudflare R2)
S3_ACCESS_KEY_IDS3 access key ID
S3_SECRET_ACCESS_KEYS3 secret access key
S3_FORCE_PATH_STYLEfalseUse path-style S3 URLs
SIGNING_KEY(disabled)Signing key <keyname>:<base64-ed25519-private>
UPLOAD_SECRET(open)Bearer token required for PUT requests
GITHUB_TOKENGitHub personal access token (for github-releases backend)
GITHUB_OWNERGitHub repository owner
GITHUB_REPOGitHub repository name
GITHUB_RELEASE_TAGnix-cacheTag name for the GitHub Release holding NAR files
GITHUB_PRUNE_RETENTION_DAYS0Days to keep orphaned release assets before pruning (0 = immediate)

Signing Keys

Signing narinfo files lets Nix verify that cached store paths haven't been tampered with. Generate a key pair with:

nix-store --generate-binary-cache-key my-cache-1 private.pem public.pem

Pass the private key to static-nix-cache via the SIGNING_KEY environment variable:

SIGNING_KEY="$(cat private.pem)" npm start

Distribute the public key (public.pem) to machines that consume the cache — add it to trusted-public-keys in their Nix configuration.