Create a copy of https://cache.nixos.org for your infrastructure
Find a file
2025-08-30 17:09:17 +02:00
modules/nixos/nixos-passthru-cache feat: add landing page 2025-08-30 17:06:22 +02:00
packages chore: remove docker deploy (#7) 2025-08-30 16:44:01 +02:00
.envrc hello world 2024-11-25 16:52:38 +01:00
.gitignore hello world 2024-11-25 16:52:38 +01:00
devshell.nix hello world 2024-11-25 16:52:38 +01:00
flake.lock hello world 2024-11-25 16:52:38 +01:00
flake.nix hello world 2024-11-25 16:52:38 +01:00
LICENSE add LICENSE 2025-08-30 17:02:24 +02:00
README.md README: revamp 2025-08-30 17:06:22 +02:00

nixos-passthru-cache

Stop paying to download the same bytes twice.

Status: Beta - solid core; interfaces may still change.

Maintained by Numtide.

What It Is

A dropin, pullthrough cache for Nix. Put it on your network, point your machines at it, and watch egress fall while builds get faster.

Who Its For

Infra and platform teams running many Nix machines - enterprises, universities, events. Anywhere repeating downloads hurt cost and speed.

Why It Matters

cache.nixos.org serves billions of requests and petabytes of data every month. Caching locally keeps those bytes close - and your bill lower.

Quick Start (Server on NixOS)

In your flake.nix:

inputs = {
  nixos-passthru-cache = {
    url = "github:numtide/nixos-passthru-cache";
    inputs.blueprint.follows = "blueprint";
    inputs.nixpkgs.follows = "nixpkgs";
  };
};

In your NixOS configuration:

{
  imports = [ inputs.nixos-passthru-cache.nixosModules.nixos-passthru-cache ];

  services.nixos-passthru-cache.enable = true;
  services.nixos-passthru-cache.hostName = "cache.example.org";
  # Optional: change upstream (defaults to https://cache.nixos.org)
  # services.nixos-passthru-cache.upstream = "https://my-upstream-cache.example";
  # Optional: adjust cache size (default 200G)
  # services.nixos-passthru-cache.cacheSize = "500G";
}

Point Clients At It

NixOS:

{
  nix.settings.extra-substituters = [ "https://cache.example.org" ];
}

nix.conf:

extra-substituters = https://cache.example.org

Validate

curl -I https://cache.example.org/nix-cache-info

Look for HTTP 200. Youll also see X-Cache-Status headers on proxied requests.

ZeroConfig LAN Mode (Bonjour/mDNS)

For trusted LANs: discoverable, noTLS, mDNS hostname (hostname.local).

{
  services.nixos-passthru-cache.enable = true;
  services.nixos-passthru-cache.lanMode = true;
  # hostName defaults to networking.hostName + ".local"
  # TLS (forceSSL) defaults to false
}

This publishes an _http._tcp Bonjour service on port 80 via Avahi and opens mDNS in the firewall.

Traffic Stats (NGINX VTS)

See traffic, hit/miss, and cache health.

  • Path: /status
  • Defaults: enabled in LAN mode; otherwise off and localhostonly

Enable explicitly when not in LAN mode:

{
  services.nixos-passthru-cache.enable = true;
  services.nixos-passthru-cache.stats.enable = true;
  # Optional: open beyond localhost
  # services.nixos-passthru-cache.stats.allowLocalOnly = false;
}

Visit https://cache.example.org/status (or http:// in LAN mode).

Demo Cache (BestEffort)

Use it from NixOS:

{
  nix.settings.extra-substituters = [ "https://hetzner-cache.numtide.com" ];
}

Or from nix.conf:

extra-substituters = https://hetzner-cache.numtide.com

Operate

  • Default cache size: 200G (tunable)
  • Ports: 80/443 (TLS on by default unless LAN mode)
  • Health: curl -I /nix-cache-info and check /status if enabled

Support

Maintained by Numtide. Issues and contributions welcome.