From 49f7e3ae2e27aca56b972c08d70f9a001d5935da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torjus=20H=C3=A5kestad?= Date: Tue, 10 Feb 2026 23:14:14 +0100 Subject: [PATCH] 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 --- services/nix-cache/proxy.nix | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/services/nix-cache/proxy.nix b/services/nix-cache/proxy.nix index f8eaab7..50340b6 100644 --- a/services/nix-cache/proxy.nix +++ b/services/nix-cache/proxy.nix @@ -1,4 +1,14 @@ -{ pkgs, ... }: +{ 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; @@ -10,7 +20,7 @@ } - nix-cache.home.2rjus.net { + ${domain} { log { output file /var/log/caddy/nix-cache.log { mode 644