another refactor partly done
This commit is contained in:
parent
3362c47211
commit
a955528e44
31 changed files with 3790 additions and 1930 deletions
|
|
@ -1,6 +1,7 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
nodes,
|
||||
...
|
||||
}:
|
||||
with lib; let
|
||||
|
|
@ -9,18 +10,13 @@ with lib; let
|
|||
nodeAgg = import ./lib/node-aggregation.nix {inherit lib;};
|
||||
in {
|
||||
imports = [
|
||||
./monitoring-config.nix
|
||||
./proxy-config.nix
|
||||
./backup-config.nix
|
||||
./motd
|
||||
./lib/systems/monitoring.nix
|
||||
./lib/systems/logging.nix
|
||||
./lib/systems/proxy.nix
|
||||
./lib/systems/backups.nix
|
||||
|
||||
./services
|
||||
|
||||
# Global aggregation modules
|
||||
(nodeAgg.mkGlobalModule "monitoring" nodeAgg.aggregators.monitoring)
|
||||
# (nodeAgg.mkGlobalModule "logs" nodeAgg.aggregators.logs)
|
||||
(nodeAgg.mkGlobalModule "reverseProxy" nodeAgg.aggregators.reverseProxy)
|
||||
(nodeAgg.mkGlobalModule "backups" nodeAgg.aggregators.backups)
|
||||
./motd
|
||||
];
|
||||
|
||||
options.homelab = {
|
||||
|
|
@ -61,73 +57,73 @@ in {
|
|||
networking.hostName = cfg.hostname;
|
||||
|
||||
# Export configuration for external consumption
|
||||
environment.etc."homelab/config.json".text = builtins.toJSON {
|
||||
inherit (cfg) hostname domain environment location tags;
|
||||
# environment.etc."homelab/config.json".text = builtins.toJSON {
|
||||
# inherit (cfg) hostname domain environment location tags;
|
||||
|
||||
monitoring = {
|
||||
# Metrics endpoints (Prometheus, etc.)
|
||||
metrics =
|
||||
map (endpoint: {
|
||||
inherit (endpoint) name host port path jobName scrapeInterval labels;
|
||||
url = "http://${endpoint.host}:${toString endpoint.port}${endpoint.path}";
|
||||
})
|
||||
cfg.global.monitoring.allMetrics or [];
|
||||
# monitoring = {
|
||||
# # Metrics endpoints (Prometheus, etc.)
|
||||
# metrics =
|
||||
# map (endpoint: {
|
||||
# inherit (endpoint) name host port path jobName scrapeInterval labels;
|
||||
# url = "http://${endpoint.host}:${toString endpoint.port}${endpoint.path}";
|
||||
# })
|
||||
# cfg.global.monitoring.allMetrics or [];
|
||||
|
||||
# Health check endpoints
|
||||
healthChecks =
|
||||
map (check: let
|
||||
# Determine the host based on useExternalDomain
|
||||
actualHost =
|
||||
if check.useExternalDomain
|
||||
then "${check.subdomain}.${cfg.externalDomain}"
|
||||
else check.host;
|
||||
# # Health check endpoints
|
||||
# healthChecks =
|
||||
# map (check: let
|
||||
# # Determine the host based on useExternalDomain
|
||||
# actualHost =
|
||||
# if check.useExternalDomain
|
||||
# then "${check.subdomain}.${cfg.externalDomain}"
|
||||
# else check.host;
|
||||
|
||||
# Build the URL
|
||||
portPart =
|
||||
if check.port != null
|
||||
then ":${toString check.port}"
|
||||
else "";
|
||||
url = "${check.protocol}://${actualHost}${portPart}${check.path}";
|
||||
in {
|
||||
inherit (check) name protocol method interval timeout conditions alerts group labels enabled;
|
||||
host = actualHost;
|
||||
port = check.port;
|
||||
path = check.path;
|
||||
url = url;
|
||||
useExternalDomain = check.useExternalDomain;
|
||||
subdomain = check.subdomain;
|
||||
sourceNode = cfg.hostname;
|
||||
})
|
||||
cfg.global.monitoring.allHealthChecks or [];
|
||||
};
|
||||
# # Build the URL
|
||||
# portPart =
|
||||
# if check.port != null
|
||||
# then ":${toString check.port}"
|
||||
# else "";
|
||||
# url = "${check.protocol}://${actualHost}${portPart}${check.path}";
|
||||
# in {
|
||||
# inherit (check) name protocol method interval timeout conditions alerts group labels enabled;
|
||||
# host = actualHost;
|
||||
# port = check.port;
|
||||
# path = check.path;
|
||||
# url = url;
|
||||
# useExternalDomain = check.useExternalDomain;
|
||||
# subdomain = check.subdomain;
|
||||
# sourceNode = cfg.hostname;
|
||||
# })
|
||||
# cfg.global.monitoring.allHealthChecks or [];
|
||||
# };
|
||||
|
||||
reverseProxy = {
|
||||
entries =
|
||||
map (entry: {
|
||||
inherit (entry) subdomain host port path enableAuth enableSSL;
|
||||
internalHost = "${cfg.hostname}:${toString entry.port}${entry.path}";
|
||||
externalHost = "${entry.subdomain}.${cfg.externalDomain}";
|
||||
})
|
||||
cfg.global.reverseProxy.all;
|
||||
};
|
||||
# reverseProxy = {
|
||||
# entries =
|
||||
# map (entry: {
|
||||
# inherit (entry) subdomain host port path enableAuth enableSSL;
|
||||
# internalHost = "${cfg.hostname}:${toString entry.port}${entry.path}";
|
||||
# externalHost = "${entry.subdomain}.${cfg.externalDomain}";
|
||||
# })
|
||||
# cfg.global.reverseProxy.all;
|
||||
# };
|
||||
|
||||
backups = {
|
||||
jobs =
|
||||
map (job: {
|
||||
inherit (job) name backend labels;
|
||||
backupId = job._backupId;
|
||||
sourceNode = job._sourceNode;
|
||||
})
|
||||
cfg.global.backups.all;
|
||||
# backups = {
|
||||
# jobs =
|
||||
# map (job: {
|
||||
# inherit (job) name backend labels;
|
||||
# backupId = job._backupId;
|
||||
# sourceNode = job._sourceNode;
|
||||
# })
|
||||
# cfg.global.backups.all;
|
||||
|
||||
backends = cfg.global.backups.allBackends;
|
||||
# backends = cfg.global.backups.allBackends;
|
||||
|
||||
summary = {
|
||||
totalJobs = length cfg.global.backups.all;
|
||||
jobsByBackend = mapAttrs (backend: jobs: length jobs) cfg.global.backups.byBackend;
|
||||
jobsByNode = mapAttrs (node: jobs: length jobs) cfg.global.backups.byNode;
|
||||
};
|
||||
};
|
||||
};
|
||||
# summary = {
|
||||
# totalJobs = length cfg.global.backups.all;
|
||||
# jobsByBackend = mapAttrs (backend: jobs: length jobs) cfg.global.backups.byBackend;
|
||||
# jobsByNode = mapAttrs (node: jobs: length jobs) cfg.global.backups.byNode;
|
||||
# };
|
||||
# };
|
||||
# };
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue