{
config,
self,
lib,
allHosts,
...
}:
let
cfg = config.custom.web-services.glance;
observabilityTitles = [
"Alloy"
"Prometheus"
"Alertmanager"
];
hosts = allHosts |> lib.attrValues;
applicationSitesWidget =
hosts
|> lib.concatMap (host: host.config.custom.meta.sites |> lib.attrValues)
|> lib.filter (service: !lib.elem service.title observabilityTitles)
|> lib.groupBy (
service:
service.domain |> self.lib.isPrivateDomain |> (isPrivate: if isPrivate then "Private" else "Public")
)
|> lib.mapAttrsToList (
name: value: {
type = "monitor";
cache = "1m";
title = "${name} Services";
sites = value;
}
)
|> (widgets: {
type = "split-column";
max-columns = 2;
inherit widgets;
});
observabilitySitesWidget =
hosts
|> lib.map (host: {
type = "monitor";
cache = "1m";
title = host.config.networking.hostName;
sites =
host.config.custom.meta.sites
|> lib.attrValues
|> lib.filter (service: lib.elem service.title observabilityTitles);
})
|> lib.filter ({ sites, ... }: sites != [ ])
|> (widgets: {
type = "split-column";
max-columns = widgets |> lib.length;
inherit widgets;
});
githubWorkflowFiles =
"${self}/.github/workflows"
|> builtins.readDir
|> lib.attrNames
|> lib.filter (file: file |> lib.hasSuffix ".yml")
|> lib.filter (file: file |> lib.hasPrefix "_" |> (hasPrefix: !hasPrefix));
mkGithubWorkflowBadge =
workflowFile:
let
workflowName = workflowFile |> lib.removeSuffix ".yml";
workflowUrl = "https://github.com/SebastianStork/nixos-config/actions/workflows/${workflowFile}";
in
''
'';
githubWorkflowBadges =
githubWorkflowFiles |> lib.map mkGithubWorkflowBadge |> lib.concatStringsSep "\n";
githubBadgeWidget = {
type = "custom-api";
title = "nixos-config";
title-url = "https://github.com/SebastianStork/nixos-config";
template = ''