main
  1{lib, ...}: {
  2  flake.modules.nixos."services/homepage" = {config, ...}: {
  3    services.homepage-dashboard = {
  4      enable = true;
  5      listenPort = 4982;
  6      openFirewall = false;
  7      allowedHosts = "home.hpcesia.com";
  8      settings = {
  9        # Basic Infomations
 10        title = "";
 11        subtitle = "HPCesia";
 12        description = "HPCesia ";
 13        favicon = "https://blog.hpcesia.com/favicon.svg";
 14        language = "zh-CN";
 15        startUrl = "https://home.hpcesia.com";
 16        base = "https://home.hpcesia.com";
 17
 18        # Appearance
 19        background = {
 20          image = "https://images.hpcesia.com/6brjyc-cf3n.webp";
 21          opacity = 60;
 22        };
 23        cardBlur = "md";
 24        theme = "dark";
 25        color = "lime";
 26        headerStyle = "clean";
 27        iconStyle = "flat";
 28        useEqualHeights = true;
 29      };
 30    };
 31
 32    services.homepage-dashboard.widgets = [
 33      {
 34        datetime = {
 35          text_size = "2xl";
 36          locale = "zh-CN";
 37          format = {
 38            dateStyle = "short";
 39            timeStyle = "short";
 40          };
 41        };
 42      }
 43    ];
 44
 45    services.homepage-dashboard.settings.layout = [
 46      {
 47        "" = {
 48          style = "row";
 49          columns = 3;
 50          tab = "";
 51        };
 52      }
 53      {
 54        NestedGroup-1 = {
 55          header = false;
 56          style = "row";
 57          columns = 2;
 58          "" = {
 59            style = "column";
 60            tab = "";
 61          };
 62          "" = {
 63            style = "column";
 64            tab = "";
 65          };
 66        };
 67      }
 68    ];
 69
 70    services.homepage-dashboard.services = [
 71      {
 72        "" = [
 73          {
 74            GitHub = {
 75              href = "https://github.com/";
 76              icon = "github.svg";
 77            };
 78          }
 79          {
 80            Codeberg = {
 81              href = "https://codeberg.org/";
 82              icon = "codeberg.svg";
 83            };
 84          }
 85          {
 86            Forgejo = {
 87              href = "https://repo.hpcesia.com/";
 88              icon = "forgejo.svg";
 89              siteMonitor = "https://repo.hpcesia.com/";
 90            };
 91          }
 92          {
 93            Cloudflare = {
 94              href = "https://dash.cloudflare.com/";
 95              icon = "cloudflare.svg";
 96            };
 97          }
 98          {
 99            Netlify = {
100              href = "https://app.netlify.com/";
101              icon = "netlify.svg";
102            };
103          }
104        ];
105      }
106      {
107        "" = [
108          {
109            Gokapi = {
110              href = "https://send.hpcesia.com/admin";
111              icon = "sh-gokapi.png";
112              siteMonitor = "https://send.hpcesia.com/";
113            };
114          }
115          {
116            GoatCounter = {
117              href = "https://goatcounter.hpcesia.com/";
118              icon = "sh-goatcounter.svg";
119              siteMonitor = "https://goatcounter.hpcesia.com/";
120            };
121          }
122          {
123            Hoppscotch = {
124              href = "https://hoppscotch.io/";
125              icon = "hoppscotch.svg";
126            };
127          }
128          {
129            Wakapi = {
130              href = "https://wakapi.hpcesia.com";
131              icon = "wakapi.svg";
132              siteMonitor = "htpps://wakapi.hpcesia.com";
133            };
134          }
135        ];
136      }
137      {
138        "" = [
139          {
140            FreshRSS = {
141              href = "https://rss.hpcesia.com/";
142              icon = "freshrss.svg";
143              siteMonitor = "https://rss.hpcesia.com/";
144            };
145          }
146          {
147            Mycelium = {
148              href = "https://myce.li/";
149              icon = "https://myce.li/favicon.ico";
150              siteMonitor = "https://myce.li/";
151            };
152          }
153          {
154            Blog = {
155              href = "https://blog.hpcesia.com/";
156              icon = "https://blog.hpcesia.com/favicon.svg";
157              siteMonitor = "https://blog.hpcesia.com/";
158            };
159          }
160        ];
161      }
162    ];
163
164    services.caddy.virtualHosts."home.hpcesia.com".extraConfig =
165      lib.mkIf config.services.caddy.enable
166      (let
167        localAddress = "http://localhost:${builtins.toString config.services.homepage-dashboard.listenPort}";
168        autheliaAddress =
169          if config.services.authelia.instances.main.enable
170          then "http://${
171            # Assuming address start with `tcp://`.
172            builtins.substring 6 (-1) config.services.authelia.instances.main.settings.server.address
173          }"
174          else "https://authelia.hpcesia.com";
175      in ''
176        encode zstd gzip
177        forward_auth ${autheliaAddress} {
178          uri /api/authz/forward-auth
179          copy_headers Remote-User Remote-Groups Remote-Email Remote-Name
180        }
181        reverse_proxy ${localAddress}
182      '');
183  };
184}