2021-11-09 01:06:53 +01:00
|
|
|
{ self }:
|
2021-11-09 01:02:26 +01:00
|
|
|
{ config, lib, pkgs, ... }: {
|
|
|
|
options.services.heliwatch = with lib; {
|
|
|
|
enable = mkEnableOption "Enable Heliwatch MUC bot";
|
|
|
|
jid = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
};
|
2024-04-13 04:16:19 +02:00
|
|
|
passwordFile = mkOption {
|
2021-11-09 01:02:26 +01:00
|
|
|
type = types.str;
|
|
|
|
};
|
|
|
|
muc = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
description = "Full Jabber-Id in the form of room@service/nickname";
|
|
|
|
};
|
|
|
|
user = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "heliwatch";
|
|
|
|
};
|
|
|
|
group = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "heliwatch";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config =
|
|
|
|
let
|
|
|
|
cfg = config.services.heliwatch;
|
|
|
|
in
|
|
|
|
lib.mkIf cfg.enable {
|
|
|
|
users = {
|
|
|
|
users.${cfg.user} = {
|
|
|
|
isSystemUser = true;
|
|
|
|
home = "/home/heliwatch";
|
|
|
|
createHome = true;
|
|
|
|
group = cfg.group;
|
|
|
|
};
|
|
|
|
groups.${cfg.group} = {};
|
|
|
|
};
|
|
|
|
|
|
|
|
systemd.services.heliwatch = {
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
after = [ "network.target" ];
|
|
|
|
path = with pkgs; [ bash curl ];
|
2024-04-13 04:16:19 +02:00
|
|
|
script = with cfg; ''
|
2021-11-09 01:02:26 +01:00
|
|
|
${./fetch_data.sh}
|
2024-04-13 04:16:19 +02:00
|
|
|
exec ${self.packages.${pkgs.system}.heliwatch}/bin/heliwatch '${jid}' "$(cat ${passwordFile})" '${muc}'
|
2021-11-09 01:02:26 +01:00
|
|
|
'';
|
|
|
|
serviceConfig = {
|
|
|
|
Type = "simple";
|
|
|
|
User = cfg.user;
|
|
|
|
Group = cfg.group;
|
|
|
|
WorkingDirectory = config.users.users.${cfg.user}.home;
|
|
|
|
ReadWritePaths = config.users.users.${cfg.user}.home;
|
|
|
|
ProtectSystem = "full";
|
|
|
|
Restart = "always";
|
|
|
|
RestartSec = "60s";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|