main
1{
2 den,
3 lib,
4 ...
5}: let
6 # Tailnet domain (base domain of Headscale MagicDNS). Tailnet reverse proxy
7 # entries are recognized by this suffix.
8 tailnetDomain = "net.trin.one";
9in {
10 den.quirks.reverseProxy.description = "Reverse proxy site entries collected from aspects (host)";
11
12 den.aspects.services.caddy.tailnetDomain = tailnetDomain;
13
14 den.policies.collect-reverse-proxy = _: let
15 inherit (den.lib.policy) pipe;
16 in [
17 (pipe.from "reverseProxy" [
18 (pipe.collect ({host, ...}: true))
19 (pipe.transform (value:
20 lib.mapAttrs
21 (domain: conf: conf // {tailscale = lib.hasSuffix ".${tailnetDomain}" domain;})
22 value))
23 pipe.withProvenance
24 ])
25 ];
26
27 den.schema.host.includes = [den.policies.collect-reverse-proxy];
28}