2024-07-03 15:46:20 +00:00
|
|
|
{
|
|
|
|
config,
|
|
|
|
pkgs,
|
|
|
|
self,
|
|
|
|
...
|
|
|
|
}:
|
|
|
|
|
|
|
|
let
|
|
|
|
name = "matrix-bot";
|
|
|
|
in
|
|
|
|
{
|
|
|
|
systemd.services.${name} = {
|
|
|
|
path = [ self.packages.${pkgs.system}.matrix-bot ];
|
|
|
|
description = "Matrix bot for changelog and reviews";
|
|
|
|
after = [ "network.target" ];
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
environment = {
|
2024-07-03 16:05:51 +00:00
|
|
|
MATRIX_PASSWORD_FILE = "%d/MATRIX_PASSWORD_FILE";
|
|
|
|
OPENAI_API_KEY_FILE = "%d/OPENAI_API_KEY_FILE";
|
2024-07-03 15:46:20 +00:00
|
|
|
HOME = "/run/${name}";
|
|
|
|
};
|
|
|
|
|
|
|
|
serviceConfig = {
|
|
|
|
LoadCredential = [
|
2024-07-03 16:05:51 +00:00
|
|
|
"MATRIX_PASSWORD_FILE:${config.sops.secrets.web01-matrix-password-clan-bot.path}"
|
|
|
|
"OPENAI_API_KEY_FILE:${config.sops.secrets.qubasas-openai-api-key.path}"
|
2024-07-03 15:46:20 +00:00
|
|
|
];
|
|
|
|
DynamicUser = true;
|
|
|
|
RuntimeDirectory = "${name}";
|
|
|
|
WorkingDirectory = "/run/${name}";
|
|
|
|
};
|
|
|
|
|
|
|
|
script = ''
|
|
|
|
set -euxo pipefail
|
|
|
|
|
|
|
|
mbot
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
}
|