From 41a49361440522529f9a74e5fd37dc3a5c4f2bd0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kier=C3=A1n=20Meinhardt?= Date: Tue, 9 Jul 2019 20:29:41 +0200 Subject: urlwatch: optionalise custom sendmail --- krebs/3modules/urlwatch.nix | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) (limited to 'krebs/3modules/urlwatch.nix') diff --git a/krebs/3modules/urlwatch.nix b/krebs/3modules/urlwatch.nix index 0cec1a2d..3213080d 100644 --- a/krebs/3modules/urlwatch.nix +++ b/krebs/3modules/urlwatch.nix @@ -17,6 +17,8 @@ let api = { enable = mkEnableOption "krebs.urlwatch"; + customSendmail.enable = mkEnableOption "krebs.urlwatch.customSendmail"; + dataDir = mkOption { type = types.str; default = "/var/lib/urlwatch"; @@ -158,19 +160,21 @@ let --urls=${shell.escape urlsFile} \ > changes || : - if test -s changes; then - { - echo Date: $(date -R) - echo From: ${shell.escape cfg.from} - echo Subject: $( - sed -n 's/^\(CHANGED\|ERROR\|NEW\): //p' changes \ - | tr '\n' ' ' - ) - echo To: ${shell.escape cfg.mailto} - echo - cat changes - } | /run/wrappers/bin/sendmail -t - fi + ${optionalString cfg.customSendmail.enable /* sh */ '' + if test -s changes; then + { + echo Date: $(date -R) + echo From: ${shell.escape cfg.from} + echo Subject: $( + sed -n 's/^\(CHANGED\|ERROR\|NEW\): //p' changes \ + | tr '\n' ' ' + ) + echo To: ${shell.escape cfg.mailto} + echo + cat changes + } | /run/wrappers/bin/sendmail -t + fi + ''} ''; }; }; -- cgit v1.2.3 From b9ab8446354378719dfa546108d4e96f7852d3d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kier=C3=A1n=20Meinhardt?= Date: Tue, 9 Jul 2019 20:30:05 +0200 Subject: urlwatch: add telegram reporting options --- krebs/3modules/urlwatch.nix | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'krebs/3modules/urlwatch.nix') diff --git a/krebs/3modules/urlwatch.nix b/krebs/3modules/urlwatch.nix index 3213080d..3c9ff770 100644 --- a/krebs/3modules/urlwatch.nix +++ b/krebs/3modules/urlwatch.nix @@ -56,6 +56,15 @@ let The format is described in systemd.time(7), CALENDAR EVENTS. ''; }; + telegram = { + enable = mkEnableOption "krebs.urlwatch.telegram" // { default = false; }; + botToken = mkOption { + type = types.str; + }; + chatId = mkOption { + type = types.listOf types.str; + }; + }; urls = mkOption { type = with types; listOf (either str subtypes.job); default = []; @@ -112,6 +121,11 @@ let color = true; enabled = true; }; + ${if cfg.telegram.enable then "telegram" else null} = { + enabled = cfg.telegram.enable; + bot_token = cfg.telegram.botToken; + chat_id = cfg.telegram.chatId; + }; text = { details = true; footer = true; -- cgit v1.2.3 From 681075a8f41ecfbac4c113481adde4d61f497c36 Mon Sep 17 00:00:00 2001 From: tv Date: Tue, 13 Aug 2019 09:29:49 +0200 Subject: urlwatch: (re-) enable sendmail by default --- krebs/3modules/urlwatch.nix | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'krebs/3modules/urlwatch.nix') diff --git a/krebs/3modules/urlwatch.nix b/krebs/3modules/urlwatch.nix index 3c9ff770..61ee72e7 100644 --- a/krebs/3modules/urlwatch.nix +++ b/krebs/3modules/urlwatch.nix @@ -16,9 +16,6 @@ let api = { enable = mkEnableOption "krebs.urlwatch"; - - customSendmail.enable = mkEnableOption "krebs.urlwatch.customSendmail"; - dataDir = mkOption { type = types.str; default = "/var/lib/urlwatch"; @@ -56,8 +53,11 @@ let The format is described in systemd.time(7), CALENDAR EVENTS. ''; }; + sendmail.enable = mkEnableOption "krebs.urlwatch.sendmail" // { + default = true; + }; telegram = { - enable = mkEnableOption "krebs.urlwatch.telegram" // { default = false; }; + enable = mkEnableOption "krebs.urlwatch.telegram"; botToken = mkOption { type = types.str; }; @@ -174,7 +174,7 @@ let --urls=${shell.escape urlsFile} \ > changes || : - ${optionalString cfg.customSendmail.enable /* sh */ '' + ${optionalString cfg.sendmail.enable /* sh */ '' if test -s changes; then { echo Date: $(date -R) -- cgit v1.2.3 From 13d7c14bd06bf22558ca13e0c213cc231c98abdb Mon Sep 17 00:00:00 2001 From: tv Date: Tue, 13 Aug 2019 09:41:55 +0200 Subject: urlwatch: filter defaults to null --- krebs/3modules/urlwatch.nix | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'krebs/3modules/urlwatch.nix') diff --git a/krebs/3modules/urlwatch.nix b/krebs/3modules/urlwatch.nix index 61ee72e7..f82e6837 100644 --- a/krebs/3modules/urlwatch.nix +++ b/krebs/3modules/urlwatch.nix @@ -75,10 +75,7 @@ let ]; apply = map (x: getAttr (typeOf x) { set = x; - string = { - url = x; - filter = null; - }; + string.url = x; }); }; verbose = mkOption { @@ -210,6 +207,7 @@ let type = types.str; }; filter = mkOption { + default = null; type = with types; nullOr str; # TODO nullOr subtypes.filter }; }; -- cgit v1.2.3 From b13d9d3149c349160e43e9ea1dbe654829b58ad9 Mon Sep 17 00:00:00 2001 From: tv Date: Tue, 13 Aug 2019 09:42:14 +0200 Subject: urlwatch: add ignore_cached option --- krebs/3modules/urlwatch.nix | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'krebs/3modules/urlwatch.nix') diff --git a/krebs/3modules/urlwatch.nix b/krebs/3modules/urlwatch.nix index f82e6837..79b45c62 100644 --- a/krebs/3modules/urlwatch.nix +++ b/krebs/3modules/urlwatch.nix @@ -210,6 +210,10 @@ let default = null; type = with types; nullOr str; # TODO nullOr subtypes.filter }; + ignore_cached = mkOption { + default = null; + type = with types; nullOr bool; + }; }; }; in out -- cgit v1.2.3 From ccb7fb731c9118f86300b2b02c987b28b079c938 Mon Sep 17 00:00:00 2001 From: tv Date: Tue, 13 Aug 2019 09:44:26 +0200 Subject: urlwatch: use writeJSON --- krebs/3modules/urlwatch.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'krebs/3modules/urlwatch.nix') diff --git a/krebs/3modules/urlwatch.nix b/krebs/3modules/urlwatch.nix index 79b45c62..43535b08 100644 --- a/krebs/3modules/urlwatch.nix +++ b/krebs/3modules/urlwatch.nix @@ -93,7 +93,7 @@ let hooksFile = cfg.hooksFile; - configFile = pkgs.writeText "urlwatch.yaml" (toJSON { + configFile = pkgs.writeJSON "urlwatch.yaml" { display = { error = true; new = true; @@ -129,7 +129,7 @@ let line_length = 75; }; }; - }); + }; imp = { systemd.timers.urlwatch = { -- cgit v1.2.3