diff --git a/configs/urlwatch.nix b/configs/urlwatch.nix index e20ebc3..be783d3 100644 --- a/configs/urlwatch.nix +++ b/configs/urlwatch.nix @@ -1,16 +1,79 @@ -{ lib, ... }: -{ - imports = [ ]; +{ pkgs, config, lib, ... }: +let + inherit (import ) kieran; - krebs.urlwatch = { - enable = true; - onCalendar = "*-*-* 05:00:00"; - sendmail.enable = false; - telegram = { - enable = true; - chatId = [ "18980945" ]; - botToken = lib.strings.fileContents ; + urlwatchDir = "/var/lib/urlwatch"; + + urlsFile = pkgs.writeText "urls" (builtins.concatStringsSep "\n---\n" (map builtins.toJSON urls)); + + urls = [ + { + name = "Corona-Verordnung"; + url = "https://www.berlin.de/corona/massnahmen/verordnung/"; + } + ]; + + configFile = pkgs.writeJSON "urlwatch.yaml" { + display = { + error = true; + new = true; + unchanged = false; + }; + report = { + email = { + enabled = true; + from = "2210@cock.li"; + html = false; + method = "smtp"; + smtp = { + host = "mail.cock.li"; + port = 587; + starttls = true; + auth = true; + insecure_password = lib.strings.fileContents ; + }; + subject = "{count} changes: {jobs}"; + to = kieran.email; + }; + html.diff = "unified"; + stdout = { + color = true; + enabled = true; + }; + telegram = { + enabled = false; + bot_token = lib.strings.fileContents ; + chat_id = [ "18980945" ]; + }; + # text = { + # details = true; + # footer = true; + # line_length = 75; + # }; + }; + }; +in +{ + users.extraUsers.urlwatch = { + home = urlwatchDir; + createHome = true; + }; + + systemd.services.urlwatch = { + enable = true; + startAt = "*-*-* 05:00:00"; + script = '' + ${pkgs.urlwatch}/bin/urlwatch \ + --config=${lib.escapeShellArg configFile} \ + --urls=${lib.escapeShellArg urlsFile} + ''; + serviceConfig = { + User = config.users.extraUsers.urlwatch.name; + WorkingDirectory = config.users.extraUsers.urlwatch.home; + PermissionsStartOnly = "true"; + PrivateTmp = "true"; + SyslogIdentifier = "urlwatch"; + Type = "oneshot"; }; - urls = [ ]; }; }