wip: nixpkgs versions + infra network + monitoring
Signed-off-by: Jeltz <jeltz@federez.net>
This commit is contained in:
parent
01b5a0fe25
commit
a64b34810d
24 changed files with 1363 additions and 513 deletions
86
modules/alertbot.nix
Normal file
86
modules/alertbot.nix
Normal file
|
@ -0,0 +1,86 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
|
||||
let
|
||||
cfg = config.services.alertbot;
|
||||
alertbot = pkgs.callPackage ../pkgs/alertbot { };
|
||||
configFile = (pkgs.formats.toml { }).generate "config.yaml" {
|
||||
listen_port = cfg.listenPort;
|
||||
matrix = {
|
||||
homeserver = cfg.matrix.homeserver;
|
||||
user = cfg.matrix.user;
|
||||
password_cred = "matrix-password";
|
||||
room_id = cfg.matrix.roomId;
|
||||
};
|
||||
};
|
||||
in {
|
||||
options.services.alertbot = {
|
||||
enable = lib.mkEnableOption "alertbot";
|
||||
|
||||
listenPort = lib.mkOption {
|
||||
type = lib.types.port;
|
||||
description = "Listen port.";
|
||||
};
|
||||
|
||||
user = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
default = "alertbot";
|
||||
description = "User under which alertbot should run.";
|
||||
};
|
||||
|
||||
group = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
default = "alertbot";
|
||||
description = "User under which alertbot should run.";
|
||||
};
|
||||
|
||||
matrix = {
|
||||
homeserver = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
description = "Homeserver URL.";
|
||||
};
|
||||
|
||||
user = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
description = "User ID.";
|
||||
};
|
||||
|
||||
passwordFile = lib.mkOption {
|
||||
type = lib.types.path;
|
||||
description = "Password file path.";
|
||||
};
|
||||
|
||||
roomId = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
description = "Room ID.";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
users.users.${cfg.user} = {
|
||||
isSystemUser = true;
|
||||
group = cfg.group;
|
||||
};
|
||||
|
||||
users.groups.${cfg.group} = { };
|
||||
|
||||
systemd.services.alertbot = {
|
||||
description = "Alertbot service";
|
||||
after = [ "network.target" ];
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
serviceConfig = {
|
||||
LoadCredential = [ "matrix-password:${cfg.matrix.passwordFile}" ];
|
||||
User = cfg.user;
|
||||
Group = cfg.group;
|
||||
ExecStart = ''
|
||||
${lib.getExe' alertbot "alertbot"} -c ${configFile}
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue