1
0
mirror of https://github.com/kmein/niveum synced 2026-03-16 10:11:08 +01:00
This commit is contained in:
Kierán Meinhardt
2019-04-21 15:22:40 +02:00
parent 9dd2895a3c
commit 9d28068dfe
11 changed files with 32 additions and 16 deletions

View File

@@ -5,6 +5,7 @@ let
in {
options.niveum.hledger = {
enable = mkEnableOption "hledger";
package = mkOption { type = types.package; default = pkgs.hledger; };
server = {
enable = mkEnableOption "hledger server";
port = mkOption { type = pkgs.unstable.lib.types.port; default = 5000; };
@@ -15,11 +16,12 @@ in {
};
flags = mkOption { type = types.listOf types.str; default = []; };
user = mkOption { type = types.attrs; };
package = mkOption { type = types.package; default = pkgs.hledger-web; };
};
};
config = mkIf cfg.enable {
environment.systemPackages = [ pkgs.unstable.hledger ];
environment.systemPackages = [ cfg.package ];
systemd.services.hledger-web = mkIf cfg.server.enable {
description = "hledger server";
@@ -28,7 +30,7 @@ in {
serviceConfig = {
Restart = "always";
ExecStart = ''
${pkgs.unstable.hledger-web}/bin/hledger-web \
${cfg.server.package}/bin/hledger-web \
--port=${toString cfg.server.port} \
--host=${cfg.server.host} \
--capabilities=${concatStringsSep "," cfg.server.capabilities} \

View File

@@ -8,14 +8,14 @@ let
startAt = bot.time;
serviceConfig.Type = "oneshot";
wants = [ "network-online.target" ];
script = ''
script = lists.concatStringsSep "\n" (map (chatId: ''
${pkgs.curl}/bin/curl -s -X POST "https://api.telegram.org/bot${bot.token}/sendMessage" \
-d chat_id="${bot.chatId}" \
-d chat_id="${chatId}" \
-d text="$(${bot.command})" ${
if bot.parseMode == null then ""
else "-d parse_mode=${bot.parseMode}"
}
'';
'') bot.chatIds);
};
in {
options.niveum.telegramBots = mkOption {
@@ -24,7 +24,7 @@ in {
enable = mkEnableOption "Telegram bot";
time = mkOption { type = types.str; };
token = mkOption { type = types.strMatching "[0-9A-Za-z:-]+"; };
chatId = mkOption { type = types.strMatching "[0-9]+|@[A-Za-z0-9]+"; };
chatIds = mkOption { type = types.listOf (types.strMatching "[0-9]+|@[A-Za-z0-9]+"); };
command = mkOption { type = types.str; };
parseMode = mkOption {
type = types.nullOr (types.enum ["HTML" "Markdown"]);