Update module

This commit is contained in:
Oystein Kristoffer Tveit 2024-08-15 23:13:16 +02:00
parent 9d75973ba7
commit b7388520e0
Signed by: oysteikt
GPG Key ID: 9F2F7D8250F35146
1 changed files with 21 additions and 0 deletions

View File

@ -45,6 +45,23 @@ in
}; };
}; };
database = {
host = mkOption {
type = types.str;
description = mdDoc "MySQL host to connect to";
example = "mysql.pvv.ntnu.no";
};
user = mkOption {
type = types.str;
description = mdDoc "MySQL username to authenticate with";
example = "calendar-bot";
};
passwordFile = mkOption {
type = types.path;
description = mdDoc "Path to file containing MySQL password";
};
};
secretsFile = mkOption { secretsFile = mkOption {
type = types.path; type = types.path;
description = mdDoc "Path to secrets file that defines MATRIX_ACCESS_TOKEN"; description = mdDoc "Path to secrets file that defines MATRIX_ACCESS_TOKEN";
@ -81,11 +98,15 @@ in
MATRIX_USER=${cfg.settings.matrix.user} MATRIX_USER=${cfg.settings.matrix.user}
ANNOUNCEMENT_CHANNEL=${cfg.settings.matrix.channel} ANNOUNCEMENT_CHANNEL=${cfg.settings.matrix.channel}
MATRIX_TOKEN=@MATRIX_ACCESS_TOKEN@ MATRIX_TOKEN=@MATRIX_ACCESS_TOKEN@
MYSQL_HOST=${cfg.settings.database.host}
MYSQL_USER=${cfg.settings.database.user}
MYSQL_PASSWORD=@MYSQL_PASSWORD@
''; '';
in in
'' ''
install -Dm600 ${envFile} /run/pvv-calendar-bot/env install -Dm600 ${envFile} /run/pvv-calendar-bot/env
${pkgs.replace-secret}/bin/replace-secret '@MATRIX_ACCESS_TOKEN@' ${cfg.settings.secretsFile} /run/pvv-calendar-bot/env ${pkgs.replace-secret}/bin/replace-secret '@MATRIX_ACCESS_TOKEN@' ${cfg.settings.secretsFile} /run/pvv-calendar-bot/env
#${pkgs.replace-secret}/bin/replace-secret '@MYSQL_PASSWORD@' ${cfg.settings.database.passwordFile} /run/pvv-calendar-bot/env
''; '';
serviceConfig = { serviceConfig = {