main
  1{
  2  lib,
  3  config,
  4  globals,
  5  ...
  6}:
  7let
  8  rheaIPs = globals.machines.rhea.net.ips;
  9  rheaVPNIPs = globals.machines.rhea.net.vpn.ips;
 10  rheaDomains = globals.machines.rhea.net.names;
 11  aionIPs = globals.machines.aion.net.ips;
 12  aionVPNIPs = globals.machines.aion.net.vpn.ips;
 13  aionDomains = globals.machines.aion.net.names;
 14
 15  # Build allowed hosts list from aion and existing rhea addresses
 16  allowedHosts = lib.concatStringsSep "," (
 17    rheaDomains
 18    ++ rheaIPs
 19    ++ rheaVPNIPs
 20    ++ aionDomains
 21    ++ aionIPs
 22    ++ aionVPNIPs
 23    ++ [
 24      "127.0.0.1"
 25      "localhost"
 26      "homepage.sbr.pm"
 27    ]
 28  );
 29
 30  # Extract syncthing machines from globals
 31  syncthingMachines = lib.filterAttrs (
 32    _name: machine: machine ? syncthing && machine.syncthing ? folders
 33  ) globals.machines;
 34
 35  # Generate syncthing service entries
 36  syncthingServices = lib.mapAttrsToList (name: _machine: {
 37    "Syncthing (${name})" = {
 38      description = "Syncthing on ${name}";
 39      href = "https://syncthing.sbr.pm/${name}/";
 40      icon = "syncthing.png";
 41      ping = "https://syncthing.sbr.pm/${name}/";
 42      statusStyle = "dot";
 43    };
 44  }) syncthingMachines;
 45in
 46{
 47  # Homepage Dashboard - Homelab Services Overview
 48  # https://gethomepage.dev
 49  #
 50  # This module provides a centralized dashboard for monitoring homelab services.
 51  # Services are configured with widgets for real-time statistics where supported.
 52  #
 53  services.homepage-dashboard = {
 54    enable = true;
 55    listenPort = 3001;
 56
 57    settings = {
 58      title = "Homelab";
 59      favicon = "https://gethomepage.dev/img/favicon.ico";
 60      theme = "dark";
 61      color = "slate";
 62
 63      layout = [
 64        {
 65          "Quick Links" = {
 66            style = "row";
 67            columns = 5;
 68          };
 69        }
 70        {
 71          Media = {
 72            style = "row";
 73            columns = 3;
 74          };
 75        }
 76        {
 77          "Download Management" = {
 78            style = "row";
 79            columns = 3;
 80          };
 81        }
 82        {
 83          "Torrent Clients" = {
 84            style = "row";
 85            columns = 2;
 86          };
 87        }
 88        {
 89          Synchronization = {
 90            style = "row";
 91            columns = 4;
 92          };
 93        }
 94        {
 95          Infrastructure = {
 96            style = "row";
 97            columns = 2;
 98          };
 99        }
100      ];
101    };
102
103    services = [
104      {
105        "Quick Links" = [
106          {
107            "Notifications" = {
108              description = "GitHub Notifications";
109              href = "https://github.com/notifications";
110              icon = "github.png";
111            };
112          }
113          {
114            "Issues" = {
115              description = "GitHub Issues";
116              href = "https://github.com/issues";
117              icon = "github.png";
118            };
119          }
120          {
121            "Pull Requests" = {
122              description = "GitHub PRs";
123              href = "https://github.com/pulls";
124              icon = "github.png";
125            };
126          }
127          {
128            "NixOS Packages" = {
129              description = "Package Search";
130              href = "https://search.nixos.org/packages";
131              icon = "nixos.png";
132            };
133          }
134          {
135            "NixOS Options" = {
136              description = "Options Search";
137              href = "https://search.nixos.org/options";
138              icon = "nixos.png";
139            };
140          }
141          {
142            "Home Manager" = {
143              description = "Options Search";
144              href = "https://home-manager-options.extranix.com";
145              icon = "nixos.png";
146            };
147          }
148          {
149            SourceHut = {
150              description = "~vdemeester";
151              href = "https://sr.ht/~vdemeester";
152              icon = "si-sourcehut";
153            };
154          }
155          {
156            Codeberg = {
157              description = "vdemeester";
158              href = "https://codeberg.org/vdemeester";
159              icon = "codeberg.png";
160            };
161          }
162          {
163            "Reading Triage" = {
164              description = "Triage Report";
165              href = "https://reading.sbr.pm/triage-report.html";
166              icon = "si-bookstack";
167            };
168          }
169          {
170            Calendar = {
171              description = "Google Calendar";
172              href = "https://calendar.google.com";
173              icon = "google-calendar.png";
174            };
175          }
176          {
177            Gmail = {
178              description = "Google Mail";
179              href = "https://mail.google.com";
180              icon = "gmail.png";
181            };
182          }
183        ];
184      }
185      {
186        Media = [
187          {
188            Jellyfin = {
189              description = "Media Server";
190              href = "https://jellyfin.sbr.pm";
191              icon = "jellyfin.png";
192              ping = "https://jellyfin.sbr.pm";
193              statusStyle = "dot";
194            };
195          }
196          {
197            Jellyseerr = {
198              description = "Media Requests";
199              href = "https://jellyseerr.sbr.pm";
200              icon = "jellyseerr.png";
201              ping = "https://jellyseerr.sbr.pm";
202              statusStyle = "dot";
203            };
204          }
205          {
206            Navidrome = {
207              description = "Music Streaming";
208              href = "https://music.sbr.pm";
209              icon = "navidrome.png";
210              ping = "https://music.sbr.pm";
211              statusStyle = "dot";
212            };
213          }
214          {
215            Audiobookshelf = {
216              description = "Podcasts & Audiobooks";
217              href = "https://podcasts.sbr.pm";
218              icon = "audiobookshelf.png";
219              ping = "https://podcasts.sbr.pm";
220              statusStyle = "dot";
221            };
222          }
223          {
224            "Liseur Sync" = {
225              description = "Ebook Library";
226              href = "https://liseur.sbr.pm";
227              icon = "si-bookstack";
228              ping = "https://liseur.sbr.pm";
229              statusStyle = "dot";
230            };
231          }
232          {
233            Immich = {
234              description = "Photo Management";
235              href = "https://immich.sbr.pm";
236              icon = "immich.png";
237              ping = "https://immich.sbr.pm";
238              statusStyle = "dot";
239            };
240          }
241        ];
242      }
243      {
244        "Download Management" = [
245          {
246            Sonarr = {
247              description = "TV Shows";
248              href = "https://sonarr.sbr.pm";
249              icon = "sonarr.png";
250              ping = "https://sonarr.sbr.pm";
251              statusStyle = "dot";
252              widget = {
253                type = "sonarr";
254                url = "https://sonarr.sbr.pm";
255                key = "{{HOMEPAGE_FILE_SONARR_KEY}}";
256              };
257            };
258          }
259          {
260            Radarr = {
261              description = "Movies";
262              href = "https://radarr.sbr.pm";
263              icon = "radarr.png";
264              ping = "https://radarr.sbr.pm";
265              statusStyle = "dot";
266              widget = {
267                type = "radarr";
268                url = "https://radarr.sbr.pm";
269                key = "{{HOMEPAGE_FILE_RADARR_KEY}}";
270              };
271            };
272          }
273          {
274            Lidarr = {
275              description = "Music";
276              href = "https://lidarr.sbr.pm";
277              icon = "lidarr.png";
278              ping = "https://lidarr.sbr.pm";
279              statusStyle = "dot";
280              widget = {
281                type = "lidarr";
282                url = "https://lidarr.sbr.pm";
283                key = "{{HOMEPAGE_FILE_LIDARR_KEY}}";
284              };
285            };
286          }
287          {
288            Bazarr = {
289              description = "Subtitles";
290              href = "https://bazarr.sbr.pm";
291              icon = "bazarr.png";
292              ping = "https://bazarr.sbr.pm";
293              statusStyle = "dot";
294            };
295          }
296          {
297            Prowlarr = {
298              description = "Indexer Manager";
299              href = "https://prowlarr.sbr.pm";
300              icon = "prowlarr.png";
301              ping = "https://prowlarr.sbr.pm";
302              statusStyle = "dot";
303            };
304          }
305        ];
306      }
307      {
308        "Torrent Clients" = [
309          {
310            Transmission = {
311              description = "General Downloads";
312              href = "https://transmission.sbr.pm";
313              icon = "transmission.png";
314              ping = "https://transmission.sbr.pm";
315              statusStyle = "dot";
316            };
317          }
318          {
319            "Transmission Music" = {
320              description = "Music Downloads";
321              href = "https://transmission-music.sbr.pm";
322              icon = "transmission.png";
323              ping = "https://transmission-music.sbr.pm";
324              statusStyle = "dot";
325            };
326          }
327        ];
328      }
329      {
330        Synchronization = syncthingServices;
331      }
332      {
333        Infrastructure = [
334          {
335            Grafana = {
336              description = "Monitoring";
337              href = "https://grafana.sbr.pm";
338              icon = "grafana.png";
339              ping = "https://grafana.sbr.pm";
340              statusStyle = "dot";
341            };
342          }
343          {
344            "Home Assistant" = {
345              description = "Home Automation";
346              href = "https://home.sbr.pm";
347              icon = "home-assistant.png";
348              ping = "https://home.sbr.pm";
349              statusStyle = "dot";
350            };
351          }
352          {
353            Traefik = {
354              description = "Reverse Proxy";
355              href = "https://traefik.sbr.pm";
356              icon = "traefik.png";
357              ping = "https://traefik.sbr.pm";
358              statusStyle = "dot";
359            };
360          }
361        ];
362      }
363      {
364        "Other Services" = [
365          {
366            Wallabag = {
367              description = "Read Later";
368              href = "https://wallabag.sbr.pm";
369              icon = "wallabag.png";
370              ping = "https://wallabag.sbr.pm";
371              statusStyle = "dot";
372            };
373          }
374          {
375            Miniflux = {
376              description = "RSS Reader";
377              href = "https://miniflux.sbr.pm";
378              icon = "miniflux.png";
379              ping = "https://miniflux.sbr.pm";
380              statusStyle = "dot";
381            };
382          }
383          {
384            Joplin = {
385              description = "Notes Sync";
386              href = "https://joplin.sbr.pm";
387              icon = "joplin.png";
388            };
389          }
390          {
391            OpenCode = {
392              description = "Remote AI Coding";
393              href = "https://opencode.sbr.pm";
394              icon = "si-terminal";
395            };
396          }
397          {
398            Paperless = {
399              description = "Document Management";
400              href = "https://paperless.sbr.pm";
401              icon = "paperless.png";
402              ping = "https://paperless.sbr.pm";
403              statusStyle = "dot";
404            };
405          }
406        ];
407      }
408    ];
409
410    bookmarks = [
411      {
412        Development = [
413          {
414            GitHub = [
415              {
416                abbr = "GH";
417                href = "https://github.com/vdemeester";
418              }
419            ];
420          }
421          {
422            "SourceHut" = [
423              {
424                abbr = "SH";
425                href = "https://sr.ht/~vdemeester";
426              }
427            ];
428          }
429          {
430            Codeberg = [
431              {
432                abbr = "CB";
433                href = "https://codeberg.org/vdemeester";
434              }
435            ];
436          }
437        ];
438      }
439      {
440        NixOS = [
441          {
442            "NixOS Search" = [
443              {
444                abbr = "NS";
445                href = "https://search.nixos.org";
446              }
447            ];
448          }
449          {
450            "NixOS Packages" = [
451              {
452                abbr = "NP";
453                href = "https://search.nixos.org/packages";
454              }
455            ];
456          }
457          {
458            "NixOS Options" = [
459              {
460                abbr = "NO";
461                href = "https://search.nixos.org/options";
462              }
463            ];
464          }
465          {
466            "Home Manager Options" = [
467              {
468                abbr = "HM";
469                href = "https://home-manager-options.extranix.com";
470              }
471            ];
472          }
473          {
474            "NixOS Wiki" = [
475              {
476                abbr = "NW";
477                href = "https://wiki.nixos.org";
478              }
479            ];
480          }
481        ];
482      }
483      {
484        Tools = [
485          {
486            "Claude Code" = [
487              {
488                abbr = "CC";
489                href = "https://claude.ai/code";
490              }
491            ];
492          }
493          {
494            "QMK Configurator" = [
495              {
496                abbr = "QMK";
497                href = "https://config.qmk.fm";
498              }
499            ];
500          }
501          {
502            "QMK Docs" = [
503              {
504                abbr = "QD";
505                href = "https://docs.qmk.fm";
506              }
507            ];
508          }
509          {
510            "Keymap Drawer" = [
511              {
512                abbr = "KD";
513                href = "https://caksoylar.github.io/keymap-drawer";
514              }
515            ];
516          }
517        ];
518      }
519      {
520        Documentation = [
521          {
522            "Homepage Docs" = [
523              {
524                abbr = "HP";
525                href = "https://gethomepage.dev";
526              }
527            ];
528          }
529          {
530            "Traefik Docs" = [
531              {
532                abbr = "TR";
533                href = "https://doc.traefik.io/traefik/";
534              }
535            ];
536          }
537          {
538            "Tekton Docs" = [
539              {
540                abbr = "TK";
541                href = "https://tekton.dev/docs/";
542              }
543            ];
544          }
545        ];
546      }
547    ];
548
549    widgets = [
550      {
551        resources = {
552          cpu = true;
553          memory = true;
554          disk = "/";
555        };
556      }
557      {
558        search = {
559          provider = "duckduckgo";
560          target = "_blank";
561        };
562      }
563    ];
564  };
565
566  # Create homepage group for secret file access
567  users.groups.homepage = { };
568
569  # Open firewall for local access
570  networking.firewall.allowedTCPPorts = [ 3001 ];
571
572  # Allow requests from aion and existing rhea domains and IPs
573  systemd.services.homepage-dashboard = {
574    environment = {
575      HOMEPAGE_ALLOWED_HOSTS = lib.mkForce allowedHosts;
576      HOMEPAGE_FILE_SONARR_KEY = config.age.secrets."exportarr-sonarr-apikey".path;
577      HOMEPAGE_FILE_RADARR_KEY = config.age.secrets."exportarr-radarr-apikey".path;
578      HOMEPAGE_FILE_LIDARR_KEY = config.age.secrets."exportarr-lidarr-apikey".path;
579    };
580    serviceConfig = {
581      SupplementaryGroups = [ "homepage" ];
582    };
583  };
584}