Skip to content

Commit

Permalink
fix module
Browse files Browse the repository at this point in the history
  • Loading branch information
Brawl345 committed Sep 7, 2024
1 parent a13c843 commit e42822a
Showing 1 changed file with 35 additions and 5 deletions.
40 changes: 35 additions & 5 deletions module.nix
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ in
description = "Admin ID";
};

botToken = mkOption {
type = types.str;
description = "Telegram Bot Token";
botTokenFile = mkOption {
type = types.path;
description = "File containing Telegram Bot Token";
};

mysqlHost = mkOption {
Expand Down Expand Up @@ -60,6 +60,18 @@ in
description = "Print all messages the bot receives";
};

prettyPrintLogs = mkOption {
type = types.bool;
default = false;
description = "Pretty print logs";
};

debug = mkOption {
type = types.bool;
default = false;
description = "Enable debug mode";
};

useWebhook = mkOption {
type = types.bool;
default = true;
Expand Down Expand Up @@ -92,13 +104,32 @@ in
};

config = mkIf cfg.enable {

# TODO
# services.mysql = lib.mkIf cfg.database.createLocally {
# enable = lib.mkDefault true;
# package = lib.mkDefault pkgs.mariadb;
# ensureDatabases = [ cfg.database.name ];
# ensureUsers = [{
# name = cfg.database.user;
# ensurePermissions = {
# "${cfg.database.name}.*" = "ALL PRIVILEGES";
# };
# }];
# };

systemd.services.gobot = {
description = "Gobot Telegram Bot";
after = [ "network.target" ];
wantedBy = [ "multi-user.target" ];

serviceConfig = {
ExecStart = "${cfg.package}/bin/gobot";
script = ''
#!/bin/sh
BOT_TOKEN='$(cat ${cfg.botTokenFile})'
${cfg.package}/bin/gobot
'';
Restart = "always";
User = cfg.user;
Group = defaultUser;
Expand All @@ -107,7 +138,6 @@ in
environment = mkMerge [
{
ADMIN_ID = toString cfg.adminId;
BOT_TOKEN = cfg.botToken;
MYSQL_HOST = cfg.mysqlHost;
MYSQL_PORT = toString cfg.mysqlPort;
MYSQL_USER = cfg.mysqlUser;
Expand Down

0 comments on commit e42822a

Please sign in to comment.