mirror of
https://github.com/SebastianStork/nixos-config.git
synced 2026-03-22 17:49:07 +01:00
glance: Group sites more sensibly
This commit is contained in:
parent
fab7e3ed3d
commit
1c80dbef8b
2 changed files with 55 additions and 17 deletions
|
|
@ -3,16 +3,20 @@
|
|||
options.custom.meta.services = lib.mkOption {
|
||||
type = lib.types.attrsOf (
|
||||
lib.types.submodule (
|
||||
{ name, ... }:
|
||||
{ name, config, ... }:
|
||||
{
|
||||
options = {
|
||||
title = lib.mkOption {
|
||||
type = lib.types.nonEmptyStr;
|
||||
default = name;
|
||||
};
|
||||
domain = lib.mkOption {
|
||||
type = lib.types.nonEmptyStr;
|
||||
default = name;
|
||||
};
|
||||
url = lib.mkOption {
|
||||
type = lib.types.nonEmptyStr;
|
||||
default = "https://${name}";
|
||||
default = "https://${config.domain}";
|
||||
};
|
||||
icon = lib.mkOption {
|
||||
type = lib.types.nonEmptyStr;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
{
|
||||
config,
|
||||
self,
|
||||
lib,
|
||||
allHosts,
|
||||
...
|
||||
|
|
@ -7,23 +8,55 @@
|
|||
let
|
||||
cfg = config.custom.web-services.glance;
|
||||
|
||||
servicesWidgets =
|
||||
allHosts
|
||||
|> lib.attrValues
|
||||
|> lib.map (host: {
|
||||
hostName = host.config.networking.hostName;
|
||||
services = host.config.custom.meta.services |> lib.attrValues;
|
||||
})
|
||||
|> lib.filter ({ services, ... }: services != [ ])
|
||||
|> lib.map (
|
||||
{ hostName, services }:
|
||||
{
|
||||
observabilityTitles = [
|
||||
"Alloy"
|
||||
"Prometheus"
|
||||
"Alertmanager"
|
||||
];
|
||||
|
||||
hosts = allHosts |> lib.attrValues;
|
||||
|
||||
applicationSites =
|
||||
hosts
|
||||
|> lib.concatMap (host: host.config.custom.meta.services |> 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 = "Services - ${hostName}";
|
||||
sites = services;
|
||||
title = "${name} Services";
|
||||
sites = value;
|
||||
}
|
||||
);
|
||||
)
|
||||
|> (widgets: {
|
||||
type = "split-column";
|
||||
max-columns = 2;
|
||||
inherit widgets;
|
||||
})
|
||||
|> lib.singleton;
|
||||
|
||||
observabilitySites =
|
||||
hosts
|
||||
|> lib.map (host: {
|
||||
type = "monitor";
|
||||
cache = "1m";
|
||||
title = host.config.networking.hostName;
|
||||
sites =
|
||||
host.config.custom.meta.services
|
||||
|> 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;
|
||||
})
|
||||
|> lib.singleton;
|
||||
in
|
||||
{
|
||||
options.custom.web-services.glance = {
|
||||
|
|
@ -57,7 +90,8 @@ in
|
|||
search-engine = "google";
|
||||
autofocus = true;
|
||||
}
|
||||
++ servicesWidgets;
|
||||
++ applicationSites
|
||||
++ observabilitySites;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue