Files
nixos-servers/services/nix-cache/proxy.nix
Torjus Håkestad 49f7e3ae2e
All checks were successful
Run nix flake check / flake-check (push) Successful in 2m18s
nix-cache: use hostname-based domain for Caddy proxy
nix-cache01 serves nix-cache.home.2rjus.net (canonical)
nix-cache02 serves nix-cache02.home.2rjus.net (for testing)

This allows testing nix-cache02 independently before DNS cutover.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-10 23:14:14 +01:00

36 lines
798 B
Nix

{ pkgs, config, ... }:
let
# nix-cache01 serves the canonical nix-cache.home.2rjus.net
# nix-cache02 serves nix-cache02.home.2rjus.net (for testing before DNS cutover)
hostname = config.networking.hostName;
domain =
if hostname == "nix-cache01" then
"nix-cache.home.2rjus.net"
else
"${hostname}.home.2rjus.net";
in
{
services.caddy = {
enable = true;
package = pkgs.unstable.caddy;
configFile = pkgs.writeText "Caddyfile" ''
{
acme_ca https://vault.home.2rjus.net:8200/v1/pki_int/acme/directory
metrics
}
${domain} {
log {
output file /var/log/caddy/nix-cache.log {
mode 644
}
}
metrics /metrics
reverse_proxy http://localhost:5000
}
'';
};
}