feat(homepage-dashboard): add services option

This commit is contained in:
Michael Thomas 2024-05-08 20:11:04 -04:00
parent ef434f6dcf
commit cd2f42a344
2 changed files with 34 additions and 10 deletions

View File

@ -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 = ''

View File

@ -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];
})