From 9e9906819dde7c303a40b2ab23818b7d91cf8cc6 Mon Sep 17 00:00:00 2001 From: Tigor Hutasuhut Date: Wed, 4 Sep 2024 20:17:37 +0700 Subject: [PATCH] caddy: tigor.web.id now has a list of hosted sites --- system/services/caddy.nix | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/system/services/caddy.nix b/system/services/caddy.nix index 6a6df5c..5ecf13a 100644 --- a/system/services/caddy.nix +++ b/system/services/caddy.nix @@ -1,7 +1,7 @@ { config, lib, ... }: let cfg = config.profile.services.caddy; - inherit (lib) mkIf; + inherit (lib) mkIf attrsets strings lists; in { config = mkIf cfg.enable { @@ -16,5 +16,36 @@ in reverse_proxy 192.168.100.1 ''; + + services.caddy.virtualHosts."tigor.web.id".extraConfig = + let + domains = attrsets.mapAttrsToList (name: _: strings.removePrefix "https://" name) config.services.caddy.virtualHosts; + sortedDomains = lists.sort (a: b: a < b) domains; + list = map (domain: /*html*/ ''
${domain}
'') sortedDomains; + items = strings.concatStringsSep "\n" list; + html = /*html*/ '' + + + Hosted Sites + + + +

Hosted Sites

+
+ ${items} +
+ + ''; + in + '' + header Content-Type text/html + respond <