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(-) 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(+) 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 f15434475faf17795bd296fc3570bc7dca34591a Mon Sep 17 00:00:00 2001 From: tv Date: Tue, 30 Jul 2019 19:20:32 +0200 Subject: tv sshd: drop default generated host key Fixes an issue with 222160fc3a195415e859048bdef21f703154b3ee which caused the generated ed25519 host key to be preferred over the one defined in krebs/3modules/*/default.nix --- tv/2configs/sshd.nix | 6 ------ 1 file changed, 6 deletions(-) diff --git a/tv/2configs/sshd.nix b/tv/2configs/sshd.nix index 1749b552..25468f23 100644 --- a/tv/2configs/sshd.nix +++ b/tv/2configs/sshd.nix @@ -5,12 +5,6 @@ with import ; { services.openssh = { enable = true; - hostKeys = [ - { - type = "ed25519"; - path = "/etc/ssh/ssh_host_ed25519_key"; - } - ]; }; tv.iptables.input-internet-accept-tcp = singleton "ssh"; } -- cgit v1.2.3 From b92610eacb6c88fe28f46a91ee8697cb542ab6aa Mon Sep 17 00:00:00 2001 From: tv Date: Fri, 2 Aug 2019 17:03:12 +0200 Subject: tv mu: reload iwlwifi on activation --- tv/1systems/mu/config.nix | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tv/1systems/mu/config.nix b/tv/1systems/mu/config.nix index f1cd7d67..98332b2d 100644 --- a/tv/1systems/mu/config.nix +++ b/tv/1systems/mu/config.nix @@ -49,6 +49,13 @@ with import ; networking.networkmanager.enable = true; + # XXX reload to work around occasional "Failed to load firmware chunk!" + # TODO only do this if firmware is actually broken(?) + system.activationScripts.reload-iwlwifi = /* sh */ '' + ${pkgs.kmod}/bin/modprobe -vr iwlwifi + ${pkgs.kmod}/bin/modprobe -v iwlwifi + ''; + environment.systemPackages = with pkgs; [ chromium firefoxWrapper -- cgit v1.2.3 From daf7c2d05d207d876f0383955e3f1c8c3f0c0822 Mon Sep 17 00:00:00 2001 From: tv Date: Mon, 5 Aug 2019 14:08:31 +0200 Subject: tv field: init --- tv/5pkgs/simple/field.nix | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 tv/5pkgs/simple/field.nix diff --git a/tv/5pkgs/simple/field.nix b/tv/5pkgs/simple/field.nix new file mode 100644 index 00000000..71362398 --- /dev/null +++ b/tv/5pkgs/simple/field.nix @@ -0,0 +1,6 @@ +{ gawk, writeDashBin }: + +writeDashBin "field" '' + set -u + exec ${gawk}/bin/awk -v n="$1" '{print$n}' +'' -- cgit v1.2.3 From 5f22fbed30828d6e297554060744f57cd2af556e Mon Sep 17 00:00:00 2001 From: tv Date: Mon, 5 Aug 2019 14:09:03 +0200 Subject: tv: add field to systemPackages --- tv/2configs/default.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/tv/2configs/default.nix b/tv/2configs/default.nix index 4fc755c4..72c48da2 100644 --- a/tv/2configs/default.nix +++ b/tv/2configs/default.nix @@ -120,6 +120,7 @@ with import ; { environment.systemPackages = [ + pkgs.field pkgs.get pkgs.git pkgs.git-crypt -- cgit v1.2.3 From 4258ff5c0c5e287c986b7199158dee1b4c49f1d9 Mon Sep 17 00:00:00 2001 From: tv Date: Mon, 12 Aug 2019 23:51:23 +0200 Subject: tv urlwatch: add json' --- tv/2configs/urlwatch.nix | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tv/2configs/urlwatch.nix b/tv/2configs/urlwatch.nix index 40dc7d23..4fb11106 100644 --- a/tv/2configs/urlwatch.nix +++ b/tv/2configs/urlwatch.nix @@ -1,8 +1,11 @@ with import ; { config, pkgs, ... }: let - json = url: { + json = json' ["."]; + json' = args: url: { inherit url; - filter = "system:${pkgs.jq}/bin/jq ."; + filter = "system:${pkgs.jq}/bin/jq ${ + concatMapStringsSep " " shell.escape (toList args) + }"; }; in { krebs.urlwatch = { -- cgit v1.2.3 From f319d31e3641ec4b9e235cb77933d5c98f0cd6a4 Mon Sep 17 00:00:00 2001 From: tv Date: Mon, 12 Aug 2019 23:51:43 +0200 Subject: tv urlwatch: add xml and xml' --- tv/2configs/urlwatch.nix | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tv/2configs/urlwatch.nix b/tv/2configs/urlwatch.nix index 4fb11106..b2364e6e 100644 --- a/tv/2configs/urlwatch.nix +++ b/tv/2configs/urlwatch.nix @@ -7,6 +7,13 @@ with import ; concatMapStringsSep " " shell.escape (toList args) }"; }; + xml = xml' ["--format" "-"]; + xml' = args: url: { + inherit url; + filter = "system:${pkgs.libxml2}/bin/xmllint ${ + concatMapStringsSep " " shell.escape (toList args) + }"; + }; in { krebs.urlwatch = { enable = true; -- cgit v1.2.3 From 8527caef164fe872dd9c77772d1e6ed7a0a85b77 Mon Sep 17 00:00:00 2001 From: tv Date: Tue, 13 Aug 2019 00:02:54 +0200 Subject: tv urlwatch: add exec --- tv/2configs/urlwatch.nix | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/tv/2configs/urlwatch.nix b/tv/2configs/urlwatch.nix index b2364e6e..378b5d16 100644 --- a/tv/2configs/urlwatch.nix +++ b/tv/2configs/urlwatch.nix @@ -1,19 +1,15 @@ with import ; { config, pkgs, ... }: let - json = json' ["."]; - json' = args: url: { + exec = filename: args: url: { inherit url; - filter = "system:${pkgs.jq}/bin/jq ${ - concatMapStringsSep " " shell.escape (toList args) + filter = "system:${ + concatMapStringsSep " " shell.escape ([filename] ++ toList args) }"; }; + json = json' ["."]; + json' = exec "${pkgs.jq}/bin/jq"; xml = xml' ["--format" "-"]; - xml' = args: url: { - inherit url; - filter = "system:${pkgs.libxml2}/bin/xmllint ${ - concatMapStringsSep " " shell.escape (toList args) - }"; - }; + xml' = exec "${pkgs.libxml2}/bin/xmllint"; in { krebs.urlwatch = { enable = true; -- cgit v1.2.3 From 9cf4d9e26f07e31cb04888c00779900c91718f1b Mon Sep 17 00:00:00 2001 From: tv Date: Tue, 13 Aug 2019 00:15:26 +0200 Subject: tv vim nix: add `comment` --- tv/5pkgs/vim/nix.nix | 40 ++++++++++++++++++---------------------- 1 file changed, 18 insertions(+), 22 deletions(-) diff --git a/tv/5pkgs/vim/nix.nix b/tv/5pkgs/vim/nix.nix index 747ab0bc..1998f9d7 100644 --- a/tv/5pkgs/vim/nix.nix +++ b/tv/5pkgs/vim/nix.nix @@ -63,16 +63,27 @@ with import ; syn cluster nix_ind_strings contains=NixIND_STRING syn cluster nix_strings contains=NixSTRING - ${concatStringsSep "\n" (mapAttrsToList (name: { + ${concatStringsSep "\n" (let + alts = xs: ''\(${concatStringsSep ''\|'' xs}\)''; + capitalize = s: let + xs = stringToCharacters s; + in + toUpper (head xs) + concatStrings (tail xs); + comment = k: ''/\* ${k} \*/''; + def = k: ''${k}[ \t\r\n]*=''; + writer = k: ''write${k}[^ \t\r\n]*[ \t\r\n]*\("[^"]*"\|[a-z]\+\)''; + writerExt = k: writerName ''[^"]*\.${k}''; + writerName = k: ''write[^ \t\r\n]*[ \t\r\n]*"${k}"''; + in mapAttrsToList (name: { extraStart ? null, lang ? name }: let startAlts = filter isString [ - ''/\* ${name} \*/'' + (comment name) extraStart ]; - sigil = ''\(${concatStringsSep ''\|'' startAlts}\)[ \t\r\n]*''; + sigil = ''${alts startAlts}[ \t\r\n]*''; in /* vim */ '' syn include @nix_${lang}_syntax syntax/${lang}.vim if exists("b:current_syntax") @@ -111,22 +122,7 @@ with import ; " This is required because containedin isn't transitive. syn cluster nix_has_dollar_curly \ add=@nix_${lang}_syntax - '') (let - - # TODO move this higher - capitalize = s: let - xs = stringToCharacters s; - in - toUpper (head xs) + concatStrings (tail xs); - - alts = xs: ''\(${concatStringsSep ''\|'' xs}\)''; - def = k: ''${k}[ \t\r\n]*=''; - writer = k: ''write${k}[^ \t\r\n]*[ \t\r\n]*\("[^"]*"\|[a-z]\+\)''; - - writerExt = k: writerName ''[^"]*\.${k}''; - writerName = k: ''write[^ \t\r\n]*[ \t\r\n]*"${k}"''; - - in { + '') { c = {}; cabal = {}; diff = {}; @@ -136,10 +132,10 @@ with import ; (writer "Jq") (writerExt "jq") ]; - javascript.extraStart = ''/\* js \*/''; + javascript.extraStart = comment "jq"; lua = {}; #nginx = {}; - python.extraStart = ''/\* py \*/''; + python.extraStart = comment "py"; sed.extraStart = writer "Sed"; sh.extraStart = let phases = [ @@ -172,7 +168,7 @@ with import ; ]; xdefaults = {}; xmodmap = {}; - }))} + })} " Clear syntax that interferes with nixINSIDE_DOLLAR_CURLY. syn clear shVarAssign -- cgit v1.2.3 From af518678bf730ee540dc3d3fe922e1f8f4fa1059 Mon Sep 17 00:00:00 2001 From: tv Date: Tue, 13 Aug 2019 00:16:54 +0200 Subject: tv vim nix: recognize python by extension --- tv/5pkgs/vim/nix.nix | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tv/5pkgs/vim/nix.nix b/tv/5pkgs/vim/nix.nix index 1998f9d7..61323ab3 100644 --- a/tv/5pkgs/vim/nix.nix +++ b/tv/5pkgs/vim/nix.nix @@ -135,7 +135,10 @@ with import ; javascript.extraStart = comment "jq"; lua = {}; #nginx = {}; - python.extraStart = comment "py"; + python.extraStart = alts [ + (comment "py") + (writerExt "py") + ]; sed.extraStart = writer "Sed"; sh.extraStart = let phases = [ -- cgit v1.2.3 From bc7c360b80409cff1bea0fe2c187c43b0eec8269 Mon Sep 17 00:00:00 2001 From: tv Date: Tue, 13 Aug 2019 00:22:59 +0200 Subject: tv vim nix writerName: recognize toFile --- tv/5pkgs/vim/nix.nix | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tv/5pkgs/vim/nix.nix b/tv/5pkgs/vim/nix.nix index 61323ab3..4f3f83aa 100644 --- a/tv/5pkgs/vim/nix.nix +++ b/tv/5pkgs/vim/nix.nix @@ -73,7 +73,8 @@ with import ; def = k: ''${k}[ \t\r\n]*=''; writer = k: ''write${k}[^ \t\r\n]*[ \t\r\n]*\("[^"]*"\|[a-z]\+\)''; writerExt = k: writerName ''[^"]*\.${k}''; - writerName = k: ''write[^ \t\r\n]*[ \t\r\n]*"${k}"''; + writerName = k: + ''${alts [''toFile'' ''write[^ \t\r\n]*'']}*[ \t\r\n]*"${k}"''; in mapAttrsToList (name: { extraStart ? null, lang ? name -- 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(-) 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