Merge remote-tracking branch 'ni/master'

This commit is contained in:
lassulus 2019-08-13 15:35:12 +02:00
commit 0699b41b05
7 changed files with 76 additions and 44 deletions

View File

@ -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
''}
'';
};
};

View File

@ -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

View File

@ -120,6 +120,7 @@ with import <stockholm/lib>;
{
environment.systemPackages = [
pkgs.field
pkgs.get
pkgs.git
pkgs.git-crypt

View File

@ -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";
}

View File

@ -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;

View File

@ -0,0 +1,6 @@
{ gawk, writeDashBin }:
writeDashBin "field" ''
set -u
exec ${gawk}/bin/awk -v n="$1" '{print$n}'
''

View File

@ -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