Commit 7dc8231

HPCesia <me@hpcesia.com>
2026-08-31 15:44:20
caddy: fmt and add comments
1 parent 85cb49b
Changed files (2)
modules
services
modules/services/caddy/default.nix
@@ -102,8 +102,8 @@
             Caddy on host '${host.name}' cannot reverse proxy to host '${srcHost.name}': no usable address is configured.
 
             Please configure an address for host '${srcHost.name}' (see `address` in modules/hosts/schema.nix), one of:
-              - clear text IPv4/IPv6           (address.ipv4.clearText / address.ipv6.clearText)
-              - secret IPv4/IPv6               (address.ipv4.secret    / address.ipv6.secret)
+              - clear text IPv4/IPv6  (address.ipv4.clearText / address.ipv6.clearText)
+              - secret IPv4/IPv6      (address.ipv4.secret    / address.ipv6.secret)
           '';
 
       entries =
@@ -126,7 +126,9 @@
           noPathCount = builtins.length noPath;
         in
           assert lib.assertMsg (noPathCount <= 1)
-          "Multiple entries without a path for domain '${name}': only one root (pathless) entry per domain is allowed, but found ${toString noPathCount}."; let
+          ("Multiple entries without a path for domain '${name}':"
+            + "only one root (pathless) entry per domain is allowed,"
+            + "but found ${toString noPathCount}."); let
             pathLines = lib.concatMap (entryBlock config) withPath;
             fallbackLines =
               if noPathCount == 1
@@ -144,7 +146,10 @@
           name = templateName e.domain;
           value = {
             content = ''
-              reverse_proxy http://${fmtAddr e.resolution.isV6 config.vaultix.placeholder.${e.resolution.secretName}}:${toString e.port}
+              reverse_proxy http://${
+                fmtAddr e.resolution.isV6
+                config.vaultix.placeholder.${e.resolution.secretName}
+              }:${toString e.port}
             '';
             owner = config.services.caddy.user;
             group = config.services.caddy.group;
modules/services/caddy/quirks.nix
@@ -7,7 +7,17 @@
   # entries are recognized by this suffix.
   tailnetDomain = "net.trin.one";
 in {
-  den.quirks.reverseProxy.description = "Reverse proxy site entries collected from aspects (host)";
+  den.quirks.reverseProxy.description = ''
+    Reverse proxy site entries collected from aspects (host)
+
+    Example:
+      domain = {
+        port = 8080; # Port the service listen
+        path = "/foo/bar" # Path to reverse proxy to
+        stripPath = false; # Whether to strip path prefix ("/foo/bar")
+        upstream = "/"; Path to reverse proxy from
+      }
+  '';
 
   den.aspects.services.caddy.tailnetDomain = tailnetDomain;