From cd2f42a3448dac7d1d23b21a3a6fea03090eaee6 Mon Sep 17 00:00:00 2001 From: Michael Thomas Date: Wed, 8 May 2024 20:11:04 -0400 Subject: [PATCH] feat(homepage-dashboard): add services option --- modules/services/forgejo/default.nix | 14 +++------ .../services/homepage-dashboard/default.nix | 30 +++++++++++++++++++ 2 files changed, 34 insertions(+), 10 deletions(-) diff --git a/modules/services/forgejo/default.nix b/modules/services/forgejo/default.nix index 5bf7892..4f80ab4 100644 --- a/modules/services/forgejo/default.nix +++ b/modules/services/forgejo/default.nix @@ -53,16 +53,10 @@ in { networking.firewall.interfaces."${firewallInterface}".allowedTCPPorts = [cfg.port]; - services.homepage-dashboard.services = [ - { - Git = { - Forgejo = { - href = url; - description = "Beyond coding. We forge."; - }; - }; - } - ]; + my.services.homepage-dashboard.services.Git.Forgejo = { + href = forgejoUrl; + description = "Beyond coding. We forge."; + }; }) (mkIf cfg.proxy { services.caddy.virtualHosts."${forgejoDomain}".extraConfig = '' diff --git a/modules/services/homepage-dashboard/default.nix b/modules/services/homepage-dashboard/default.nix index f8bd405..52a81ef 100644 --- a/modules/services/homepage-dashboard/default.nix +++ b/modules/services/homepage-dashboard/default.nix @@ -23,6 +23,21 @@ in { default = 8082; description = "HTTP port for the homepage-dashboard service."; }; + services = mkOption { + type = types.attrs; + default = {}; + description = "Attrset of services by group."; + example = '' + { + Group = { + App = { + href = "https://example.com"; + description = "An amazing app!"; + }; + }; + } + ''; + }; }; config = mkMerge [ @@ -30,7 +45,22 @@ in { services.homepage-dashboard = { enable = true; listenPort = cfg.port; + settings.logpath = "/var/log/homepage-dashboard"; + # Convert services to YAML format + services = + lib.mapAttrsToList ( + groupName: groupAttrs: { + ${groupName} = ( + lib.mapAttrsToList ( + serviceName: serviceAttrs: {${serviceName} = serviceAttrs;} + ) + groupAttrs + ); + } + ) + cfg.services; }; + systemd.services.homepage-dashboard.environment.LOG_TARGETS = "stdout"; networking.firewall.interfaces."${firewallInterface}".allowedTCPPorts = [cfg.port]; })