fix(exports): enable base services by default

This commit is contained in:
arcnmx 2024-05-30 13:13:11 -07:00
parent 77fd991ed1
commit a1273971d9
14 changed files with 36 additions and 67 deletions

View file

@ -3,8 +3,27 @@
gensokyo-zone,
...
}: let
inherit (gensokyo-zone.lib) mapAlmostOptionDefaults mkAlmostOptionDefault;
inherit (gensokyo-zone.lib) mapListToAttrs mapAlmostOptionDefaults mkAlmostOptionDefault;
inherit (lib.modules) mkIf;
inherit (lib.attrsets) nameValuePair;
mkExporter = { name, port }: nameValuePair "prometheus-exporters-${name}" ({config, ...}: {
nixos = {
serviceAttrPath = ["services" "prometheus" "exporters" name];
assertions = mkIf config.enable [
(nixosConfig: {
assertion = config.ports.default.port == nixosConfig.services.prometheus.exporters.${name}.port;
message = "port mismatch";
})
];
};
ports.default = mapAlmostOptionDefaults {
inherit port;
protocol = "http";
};
});
exporters = mapListToAttrs mkExporter [
{ name = "node"; port = 9091; }
];
in {
config.exports.services = {
prometheus = {config, ...}: {
@ -23,22 +42,6 @@ in {
protocol = "http";
};
};
prometheus-exporters-node = {config, ...}: {
id = mkAlmostOptionDefault "prometheus-exporters-node";
nixos = {
serviceAttrPath = ["services" "prometheus" "exporters" "node"];
assertions = mkIf config.enable [
(nixosConfig: {
assertion = config.ports.default.port == nixosConfig.services.prometheus.exporters.node.port;
message = "port mismatch";
})
];
};
ports.default = mapAlmostOptionDefaults {
port = 9091;
protocol = "http";
};
};
grafana = {config, ...}: {
id = mkAlmostOptionDefault "grafana";
nixos = {
@ -87,5 +90,5 @@ in {
protocol = "http";
};
};
};
} // exporters;
}