diff options
author | lassulus <lassulus@lassul.us> | 2019-08-13 15:35:12 +0200 |
---|---|---|
committer | lassulus <lassulus@lassul.us> | 2019-08-13 15:35:12 +0200 |
commit | 0699b41b05a1f9cd133c15c3aadf70c3a45170f6 (patch) | |
tree | 0bdd752d8a9ec64acb12ff160826a19b2e11e95c | |
parent | e754ced01e2d5ef84dabba391bba2f372694b7cb (diff) | |
parent | 681075a8f41ecfbac4c113481adde4d61f497c36 (diff) |
Merge remote-tracking branch 'ni/master'
-rw-r--r-- | krebs/3modules/urlwatch.nix | 46 | ||||
-rw-r--r-- | tv/1systems/mu/config.nix | 7 | ||||
-rw-r--r-- | tv/2configs/default.nix | 1 | ||||
-rw-r--r-- | tv/2configs/sshd.nix | 6 | ||||
-rw-r--r-- | tv/2configs/urlwatch.nix | 10 | ||||
-rw-r--r-- | tv/5pkgs/simple/field.nix | 6 | ||||
-rw-r--r-- | tv/5pkgs/vim/nix.nix | 44 |
7 files changed, 76 insertions, 44 deletions
diff --git a/krebs/3modules/urlwatch.nix b/krebs/3modules/urlwatch.nix index 0cec1a2d3..61ee72e74 100644 --- a/krebs/3modules/urlwatch.nix +++ b/krebs/3modules/urlwatch.nix @@ -16,7 +16,6 @@ let api = { enable = mkEnableOption "krebs.urlwatch"; - dataDir = mkOption { type = types.str; default = "/var/lib/urlwatch"; @@ -54,6 +53,18 @@ 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"; + botToken = mkOption { + type = types.str; + }; + chatId = mkOption { + type = types.listOf types.str; + }; + }; urls = mkOption { type = with types; listOf (either str subtypes.job); default = []; @@ -110,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; @@ -158,19 +174,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.sendmail.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 + ''} ''; }; }; diff --git a/tv/1systems/mu/config.nix b/tv/1systems/mu/config.nix index f1cd7d673..98332b2d6 100644 --- a/tv/1systems/mu/config.nix +++ b/tv/1systems/mu/config.nix @@ -49,6 +49,13 @@ with import <stockholm/lib>; 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 diff --git a/tv/2configs/default.nix b/tv/2configs/default.nix index 4fc755c43..72c48da2c 100644 --- a/tv/2configs/default.nix +++ b/tv/2configs/default.nix @@ -120,6 +120,7 @@ with import <stockholm/lib>; { environment.systemPackages = [ + pkgs.field pkgs.get pkgs.git pkgs.git-crypt diff --git a/tv/2configs/sshd.nix b/tv/2configs/sshd.nix index 1749b552d..25468f23e 100644 --- a/tv/2configs/sshd.nix +++ b/tv/2configs/sshd.nix @@ -5,12 +5,6 @@ with import <stockholm/lib>; { services.openssh = { enable = true; - hostKeys = [ - { - type = "ed25519"; - path = "/etc/ssh/ssh_host_ed25519_key"; - } - ]; }; tv.iptables.input-internet-accept-tcp = singleton "ssh"; } diff --git a/tv/2configs/urlwatch.nix b/tv/2configs/urlwatch.nix index 40dc7d237..378b5d167 100644 --- a/tv/2configs/urlwatch.nix +++ b/tv/2configs/urlwatch.nix @@ -1,9 +1,15 @@ with import <stockholm/lib>; { config, pkgs, ... }: let - json = url: { + exec = filename: args: url: { inherit url; - filter = "system:${pkgs.jq}/bin/jq ."; + filter = "system:${ + concatMapStringsSep " " shell.escape ([filename] ++ toList args) + }"; }; + json = json' ["."]; + json' = exec "${pkgs.jq}/bin/jq"; + xml = xml' ["--format" "-"]; + xml' = exec "${pkgs.libxml2}/bin/xmllint"; in { krebs.urlwatch = { enable = true; diff --git a/tv/5pkgs/simple/field.nix b/tv/5pkgs/simple/field.nix new file mode 100644 index 000000000..71362398d --- /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}' +'' diff --git a/tv/5pkgs/vim/nix.nix b/tv/5pkgs/vim/nix.nix index 747ab0bc0..4f3f83aaa 100644 --- a/tv/5pkgs/vim/nix.nix +++ b/tv/5pkgs/vim/nix.nix @@ -63,16 +63,28 @@ with import <stockholm/lib>; 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: + ''${alts [''toFile'' ''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 +123,7 @@ with import <stockholm/lib>; " 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 +133,13 @@ with import <stockholm/lib>; (writer "Jq") (writerExt "jq") ]; - javascript.extraStart = ''/\* js \*/''; + javascript.extraStart = comment "jq"; lua = {}; #nginx = {}; - python.extraStart = ''/\* py \*/''; + python.extraStart = alts [ + (comment "py") + (writerExt "py") + ]; sed.extraStart = writer "Sed"; sh.extraStart = let phases = [ @@ -172,7 +172,7 @@ with import <stockholm/lib>; ]; xdefaults = {}; xmodmap = {}; - }))} + })} " Clear syntax that interferes with nixINSIDE_DOLLAR_CURLY. syn clear shVarAssign |