mirror of
https://github.com/SebastianStork/nixos-config.git
synced 2026-03-22 21:19: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 {
|
options.custom.meta.services = lib.mkOption {
|
||||||
type = lib.types.attrsOf (
|
type = lib.types.attrsOf (
|
||||||
lib.types.submodule (
|
lib.types.submodule (
|
||||||
{ name, ... }:
|
{ name, config, ... }:
|
||||||
{
|
{
|
||||||
options = {
|
options = {
|
||||||
title = lib.mkOption {
|
title = lib.mkOption {
|
||||||
type = lib.types.nonEmptyStr;
|
type = lib.types.nonEmptyStr;
|
||||||
default = name;
|
default = name;
|
||||||
};
|
};
|
||||||
|
domain = lib.mkOption {
|
||||||
|
type = lib.types.nonEmptyStr;
|
||||||
|
default = name;
|
||||||
|
};
|
||||||
url = lib.mkOption {
|
url = lib.mkOption {
|
||||||
type = lib.types.nonEmptyStr;
|
type = lib.types.nonEmptyStr;
|
||||||
default = "https://${name}";
|
default = "https://${config.domain}";
|
||||||
};
|
};
|
||||||
icon = lib.mkOption {
|
icon = lib.mkOption {
|
||||||
type = lib.types.nonEmptyStr;
|
type = lib.types.nonEmptyStr;
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
{
|
{
|
||||||
config,
|
config,
|
||||||
|
self,
|
||||||
lib,
|
lib,
|
||||||
allHosts,
|
allHosts,
|
||||||
...
|
...
|
||||||
|
|
@ -7,23 +8,55 @@
|
||||||
let
|
let
|
||||||
cfg = config.custom.web-services.glance;
|
cfg = config.custom.web-services.glance;
|
||||||
|
|
||||||
servicesWidgets =
|
observabilityTitles = [
|
||||||
allHosts
|
"Alloy"
|
||||||
|> lib.attrValues
|
"Prometheus"
|
||||||
|> lib.map (host: {
|
"Alertmanager"
|
||||||
hostName = host.config.networking.hostName;
|
];
|
||||||
services = host.config.custom.meta.services |> lib.attrValues;
|
|
||||||
})
|
hosts = allHosts |> lib.attrValues;
|
||||||
|> lib.filter ({ services, ... }: services != [ ])
|
|
||||||
|> lib.map (
|
applicationSites =
|
||||||
{ hostName, services }:
|
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";
|
type = "monitor";
|
||||||
cache = "1m";
|
cache = "1m";
|
||||||
title = "Services - ${hostName}";
|
title = "${name} Services";
|
||||||
sites = 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
|
in
|
||||||
{
|
{
|
||||||
options.custom.web-services.glance = {
|
options.custom.web-services.glance = {
|
||||||
|
|
@ -57,7 +90,8 @@ in
|
||||||
search-engine = "google";
|
search-engine = "google";
|
||||||
autofocus = true;
|
autofocus = true;
|
||||||
}
|
}
|
||||||
++ servicesWidgets;
|
++ applicationSites
|
||||||
|
++ observabilitySites;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue