diff --git a/custom.template.nix b/custom.template.nix index 81b0016..70ee7f1 100644 --- a/custom.template.nix +++ b/custom.template.nix @@ -22,4 +22,20 @@ # ─── Add your custom NixOS configuration below ─────────── + # ─── Custom Caddy virtual hosts ────────────────────────── + # Uncomment and edit below to add your own Caddy sites: + # + # sovran_systemsOS.caddy.extraVirtualHosts = '' + # mysite.example.com { + # encode gzip zstd + # root * /var/lib/www/mysite + # php_fastcgi unix//run/phpfpm/mypool.sock + # file_server browse + # } + # + # anotherdomain.com { + # reverse_proxy localhost:9090 + # } + # ''; + } \ No newline at end of file diff --git a/modules/core/caddy.nix b/modules/core/caddy.nix index 7f4d811..15b0cba 100755 --- a/modules/core/caddy.nix +++ b/modules/core/caddy.nix @@ -2,6 +2,7 @@ let exposeBtcpay = config.sovran_systemsOS.web.btcpayserver; + extraVhosts = config.sovran_systemsOS.caddy.extraVirtualHosts; in { services.caddy = { @@ -170,6 +171,11 @@ EOF encode gzip zstd } EOF + + # ── Custom vhosts from custom.nix ────────────── + cat >> /run/caddy/Caddyfile <<'CUSTOM_VHOSTS_EOF' +${extraVhosts} +CUSTOM_VHOSTS_EOF ''; }; } diff --git a/modules/core/roles.nix b/modules/core/roles.nix index 2de80d5..95d5a2e 100755 --- a/modules/core/roles.nix +++ b/modules/core/roles.nix @@ -60,6 +60,15 @@ }; }; + # ── Caddy customisation ─────────────────────────────────── + caddy = { + extraVirtualHosts = lib.mkOption { + type = lib.types.lines; + default = ""; + description = "Additional raw Caddyfile blocks appended to the generated Caddy config. Use this in custom.nix to add custom domains and reverse proxies."; + }; + }; + # ── Domain setup registry ───────────────────────────────── domainRequirements = lib.mkOption { type = lib.types.listOf (lib.types.submodule {