mob next [ci-skip] [ci skip] [skip ci]
lastFile:inventories/default.nix
This commit is contained in:
@@ -10,7 +10,7 @@
|
||||
description = "Prometheus server that scraps all data from nodes";
|
||||
|
||||
interface =
|
||||
{ lib, ... }:
|
||||
{ lib, options, ... }:
|
||||
{
|
||||
options = {
|
||||
scrape_interval = lib.mkOption {
|
||||
@@ -30,6 +30,23 @@
|
||||
};
|
||||
description = "Definition of a default receiver, default is doing nothing";
|
||||
};
|
||||
matrix-alertmanager = {
|
||||
enable = lib.mkOption {
|
||||
type = with lib.types; bool;
|
||||
default = false;
|
||||
description = "Whether to enable `services.matrix-alertmanager`";
|
||||
};
|
||||
homeserverUrl = lib.mkOption {
|
||||
type = with lib.types; str;
|
||||
default = "https://matrix-client.matrix.org";
|
||||
description = "URL of the Matrix homeserver to use";
|
||||
};
|
||||
matrixUser = lib.mkOption {
|
||||
type = with lib.types; str;
|
||||
description = "Matrix user for the bot";
|
||||
};
|
||||
matrixRooms = options.services.matrix-alertmanager.matrixRooms;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
@@ -161,7 +178,39 @@
|
||||
|
||||
};
|
||||
|
||||
};
|
||||
}
|
||||
// lib.optionalAttrs settings.matrix-alertmanager.enable (
|
||||
{ pkgs, ... }:
|
||||
{
|
||||
clan.core.vars.generators.prometheus = {
|
||||
files.matrix-alertmanager-token.secret = true;
|
||||
files.matrix-alertmanager-secret.secret = true;
|
||||
files.matrix-alertmanager-urlfile = {
|
||||
secret = true;
|
||||
owner = "alertmanager";
|
||||
group = "alertmanager";
|
||||
};
|
||||
script = ''
|
||||
echo "" > $out/matrix-alertmanager-token
|
||||
openssl rand -hex 32 > "$out"/matrix-alertmanager-secret
|
||||
|
||||
echo "http://localhost:3000/alerts?secret=$(cat $out/matrix-alertmanager-secret)" > $out/matrix-alertmanager-urlfile
|
||||
'';
|
||||
runtimeInputs = [
|
||||
pkgs.openssl
|
||||
];
|
||||
};
|
||||
|
||||
services.matrix-alertmanager = lib.mkIf settings.matrix-alertmanager.enable {
|
||||
enable = true;
|
||||
tokenFile = config.clan.core.vars.generators.prometheus.files.matrix-alertmanager-token.path;
|
||||
secretFile = config.clan.core.vars.generators.prometheus.files.matrix-alertmanager-secret.path;
|
||||
homeserverUrl = settings.matrix-alertmanager.homeserverUrl;
|
||||
matrixUser = settings.matrix-alertmanager.matrixUser;
|
||||
matrixRooms = settings.matrix-alertmanager.matrixRooms;
|
||||
};
|
||||
}
|
||||
);
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user