mirror of
https://github.com/kmein/niveum
synced 2026-03-16 10:11:08 +01:00
feat(panoptikon): add library to flake outputs and use
This commit is contained in:
@@ -54,11 +54,16 @@
|
|||||||
traadfri = import modules/traadfri.nix;
|
traadfri = import modules/traadfri.nix;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
lib = {
|
||||||
|
panoptikon = import lib/panoptikon.nix;
|
||||||
|
};
|
||||||
|
|
||||||
nixosConfigurations = {
|
nixosConfigurations = {
|
||||||
ful = nixpkgs.lib.nixosSystem rec {
|
ful = nixpkgs.lib.nixosSystem rec {
|
||||||
system = "aarch64-linux";
|
system = "aarch64-linux";
|
||||||
specialArgs = {
|
specialArgs = {
|
||||||
niveumPackages = inputs.self.packages.${system};
|
niveumPackages = inputs.self.packages.${system};
|
||||||
|
niveumLib = inputs.self.lib;
|
||||||
inherit inputs;
|
inherit inputs;
|
||||||
};
|
};
|
||||||
modules = [
|
modules = [
|
||||||
|
|||||||
45
lib/panoptikon.nix
Normal file
45
lib/panoptikon.nix
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
{
|
||||||
|
pkgs,
|
||||||
|
lib,
|
||||||
|
niveumPackages,
|
||||||
|
config,
|
||||||
|
...
|
||||||
|
}: {
|
||||||
|
# watcher scripts
|
||||||
|
url = address:
|
||||||
|
pkgs.writers.writeDash "watch-url" ''
|
||||||
|
${pkgs.curl}/bin/curl -sSL ${lib.escapeShellArg address} \
|
||||||
|
| ${pkgs.python3Packages.html2text}/bin/html2text
|
||||||
|
'';
|
||||||
|
urlSelector = selector: address:
|
||||||
|
pkgs.writers.writeDash "watch-url-selector" ''
|
||||||
|
${pkgs.curl}/bin/curl -sSL ${lib.escapeShellArg address} \
|
||||||
|
| ${pkgs.htmlq}/bin/htmlq ${lib.escapeShellArg selector} \
|
||||||
|
| ${pkgs.python3Packages.html2text}/bin/html2text
|
||||||
|
'';
|
||||||
|
urlJSON = {jqScript ? "."}: address:
|
||||||
|
pkgs.writers.writeDash "watch-url-json" ''
|
||||||
|
${pkgs.curl}/bin/curl -sSL ${lib.escapeShellArg address} | ${pkgs.jq}/bin/jq -f ${pkgs.writeText "script.jq" jqScript}
|
||||||
|
'';
|
||||||
|
|
||||||
|
# reporter scripts
|
||||||
|
kpaste-irc = {
|
||||||
|
target,
|
||||||
|
retiolumLink ? false,
|
||||||
|
server ? "irc.r",
|
||||||
|
messagePrefix ? "change detected: ",
|
||||||
|
nick ? ''"$PANOPTIKON_WATCHER"-watcher'',
|
||||||
|
}:
|
||||||
|
pkgs.writers.writeDash "kpaste-irc-reporter" ''
|
||||||
|
${niveumPackages.kpaste}/bin/kpaste \
|
||||||
|
| ${pkgs.gnused}/bin/sed -n "${
|
||||||
|
if retiolumLink
|
||||||
|
then "2"
|
||||||
|
else "3"
|
||||||
|
}s/^/${messagePrefix}/p" \
|
||||||
|
| ${config.nur.repos.mic92.ircsink}/bin/ircsink \
|
||||||
|
--nick ${nick} \
|
||||||
|
--server ${server} \
|
||||||
|
--target ${target}
|
||||||
|
'';
|
||||||
|
}
|
||||||
@@ -110,7 +110,7 @@
|
|||||||
environment.PANOPTIKON_WATCHER = watcherName;
|
environment.PANOPTIKON_WATCHER = watcherName;
|
||||||
wants = ["network-online.target"];
|
wants = ["network-online.target"];
|
||||||
script = ''
|
script = ''
|
||||||
set -efux
|
set -efu
|
||||||
|
|
||||||
${watcherOptions.script} > ${watcherName}
|
${watcherOptions.script} > ${watcherName}
|
||||||
${pkgs.git}/bin/git add ${watcherName}
|
${pkgs.git}/bin/git add ${watcherName}
|
||||||
|
|||||||
@@ -2,128 +2,106 @@
|
|||||||
config,
|
config,
|
||||||
pkgs,
|
pkgs,
|
||||||
lib,
|
lib,
|
||||||
|
niveumLib,
|
||||||
|
niveumPackages,
|
||||||
...
|
...
|
||||||
}: let
|
}: let
|
||||||
kpaste = pkgs.writers.writeDash "kpaste" ''
|
panoptikon = niveumLib.panoptikon {inherit pkgs lib niveumPackages config;};
|
||||||
${pkgs.curl}/bin/curl -sS -sS http://p.r --data-binary @"''${1:--}" | ${pkgs.gnused}/bin/sed '$ {p;s|http://p.r|https://p.krebsco.de|}'
|
|
||||||
'';
|
|
||||||
|
|
||||||
url = address:
|
irc-xxx = panoptikon.kpaste-irc {
|
||||||
pkgs.writers.writeDash "watch-url" ''
|
target = "#xxx";
|
||||||
${pkgs.w3m}/bin/w3m -dump ${lib.escapeShellArg address}
|
retiolumLink = true;
|
||||||
'';
|
};
|
||||||
|
|
||||||
urlJSON = address:
|
irc-kmein = panoptikon.kpaste-irc {
|
||||||
pkgs.writers.writeDash "watch-url-json" ''
|
messagePrefix = "$PANOPTIKON_WATCHER: ";
|
||||||
${pkgs.curl}/bin/curl -sSL ${lib.escapeShellArg address} | ${pkgs.jq}/bin/jq
|
target = "kmein";
|
||||||
'';
|
nick = "panoptikon-kmein";
|
||||||
|
retiolumLink = false;
|
||||||
urlSelector = selector: address:
|
};
|
||||||
pkgs.writers.writeDash "watch-url-selector" ''
|
|
||||||
${pkgs.curl}/bin/curl -sSL ${lib.escapeShellArg address} \
|
|
||||||
| ${pkgs.htmlq}/bin/htmlq ${lib.escapeShellArg selector} \
|
|
||||||
| ${pkgs.python3Packages.html2text}/bin/html2text
|
|
||||||
'';
|
|
||||||
|
|
||||||
reporters.irc-xxx = pkgs.writers.writeDash "irc-xxx" ''
|
|
||||||
${kpaste} \
|
|
||||||
| ${pkgs.gnused}/bin/sed -n '2s/^/change detected: /p' \
|
|
||||||
| ${config.nur.repos.mic92.ircsink}/bin/ircsink \
|
|
||||||
--nick "$PANOPTIKON_WATCHER"-watcher \
|
|
||||||
--server irc.r \
|
|
||||||
--target '#xxx'
|
|
||||||
'';
|
|
||||||
|
|
||||||
reporters.irc-kmein = pkgs.writers.writeDash "irc-xxx" ''
|
|
||||||
${kpaste} \
|
|
||||||
| ${pkgs.gnused}/bin/sed -n "3s/^/$PANOPTIKON_WATCHER: /p" \
|
|
||||||
| ${config.nur.repos.mic92.ircsink}/bin/ircsink \
|
|
||||||
--nick panoptikon-kmein \
|
|
||||||
--server irc.r \
|
|
||||||
--target 'kmein'
|
|
||||||
'';
|
|
||||||
in {
|
in {
|
||||||
services.panoptikon = {
|
services.panoptikon = {
|
||||||
enable = true;
|
enable = true;
|
||||||
watchers = {
|
watchers = {
|
||||||
"github-meta" = {
|
"github-meta" = {
|
||||||
script = urlJSON "https://api.github.com/meta";
|
script = panoptikon.urlJSON {} "https://api.github.com/meta";
|
||||||
reporters = [reporters.irc-xxx];
|
reporters = [irc-xxx];
|
||||||
};
|
};
|
||||||
lammla = {
|
lammla = {
|
||||||
script = url "http://lammla.info/index.php?reihe=30";
|
script = panoptikon.url "http://lammla.info/index.php?reihe=30";
|
||||||
reporters = [reporters.irc-kmein];
|
reporters = [irc-kmein];
|
||||||
};
|
};
|
||||||
kratylos = {
|
kratylos = {
|
||||||
script = url "https://kratylos.reichert-online.org/current_issue/KRATYLOS";
|
script = panoptikon.url "https://kratylos.reichert-online.org/current_issue/KRATYLOS";
|
||||||
reporters = [reporters.irc-kmein];
|
reporters = [irc-kmein];
|
||||||
};
|
};
|
||||||
zeno-free = {
|
zeno-free = {
|
||||||
script = urlSelector ".zenoCOMain" "http://www.zeno.org/Lesesaal/M/E-Books";
|
script = panoptikon.urlSelector ".zenoCOMain" "http://www.zeno.org/Lesesaal/M/E-Books";
|
||||||
reporters = [reporters.irc-kmein];
|
reporters = [irc-kmein];
|
||||||
};
|
};
|
||||||
carolinawelslau = {
|
carolinawelslau = {
|
||||||
script = urlSelector "#main" "https://carolinawelslau.de/";
|
script = panoptikon.urlSelector "#main" "https://carolinawelslau.de/";
|
||||||
reporters = [reporters.irc-kmein];
|
reporters = [irc-kmein];
|
||||||
};
|
};
|
||||||
lisalittmann = {
|
lisalittmann = {
|
||||||
script = urlSelector "#site-content" "https://lisalittmann.de/";
|
script = panoptikon.urlSelector "#site-content" "https://lisalittmann.de/";
|
||||||
reporters = [reporters.irc-kmein];
|
reporters = [irc-kmein];
|
||||||
};
|
};
|
||||||
lisalittmann-archive = {
|
lisalittmann-archive = {
|
||||||
script = urlSelector "#site-content" "https://lisalittmann.de/archive/";
|
script = panoptikon.urlSelector "#site-content" "https://lisalittmann.de/archive/";
|
||||||
reporters = [reporters.irc-kmein];
|
reporters = [irc-kmein];
|
||||||
};
|
};
|
||||||
lisalittmann-projects = {
|
lisalittmann-projects = {
|
||||||
script = urlSelector "#site-content" "https://lisalittmann.de/projects/";
|
script = panoptikon.urlSelector "#site-content" "https://lisalittmann.de/projects/";
|
||||||
reporters = [reporters.irc-kmein];
|
reporters = [irc-kmein];
|
||||||
};
|
};
|
||||||
tatort = {
|
tatort = {
|
||||||
script = urlSelector ".linklist" "https://www.daserste.de/unterhaltung/krimi/tatort/sendung/index.html";
|
script = panoptikon.urlSelector ".linklist" "https://www.daserste.de/unterhaltung/krimi/tatort/sendung/index.html";
|
||||||
reporters = [reporters.irc-kmein];
|
reporters = [irc-kmein];
|
||||||
};
|
};
|
||||||
warpgrid-idiomarium = {
|
warpgrid-idiomarium = {
|
||||||
script = urlSelector "#site-content" "https://warpgrid.de/idiomarium/";
|
script = panoptikon.urlSelector "#site-content" "https://warpgrid.de/idiomarium/";
|
||||||
reporters = [reporters.irc-kmein];
|
reporters = [irc-kmein];
|
||||||
};
|
};
|
||||||
warpgrid-futurism = {
|
warpgrid-futurism = {
|
||||||
script = urlSelector "#site-content" "https://warpgrid.de/futurism/";
|
script = panoptikon.urlSelector "#site-content" "https://warpgrid.de/futurism/";
|
||||||
reporters = [reporters.irc-kmein];
|
reporters = [irc-kmein];
|
||||||
};
|
};
|
||||||
warpgrid-imagiary = {
|
warpgrid-imagiary = {
|
||||||
script = urlSelector "#site-content" "https://warpgrid.de/imagiary/";
|
script = panoptikon.urlSelector "#site-content" "https://warpgrid.de/imagiary/";
|
||||||
reporters = [reporters.irc-kmein];
|
reporters = [irc-kmein];
|
||||||
};
|
};
|
||||||
warpgrid-alchemy = {
|
warpgrid-alchemy = {
|
||||||
script = urlSelector "#site-content" "https://warpgrid.de/alchemy/";
|
script = panoptikon.urlSelector "#site-content" "https://warpgrid.de/alchemy/";
|
||||||
reporters = [reporters.irc-kmein];
|
reporters = [irc-kmein];
|
||||||
};
|
};
|
||||||
indogermanische-forschungen = {
|
indogermanische-forschungen = {
|
||||||
script = urlSelector "#latestIssue" "https://www.degruyter.com/journal/key/INDO/html";
|
script = panoptikon.urlSelector "#latestIssue" "https://www.degruyter.com/journal/key/INDO/html";
|
||||||
reporters = [reporters.irc-kmein];
|
reporters = [irc-kmein];
|
||||||
};
|
};
|
||||||
ig-neuigkeiten = {
|
ig-neuigkeiten = {
|
||||||
script = urlSelector "[itemprop=articleBody]" "https://www.indogermanistik.org/aktuelles/neuigkeiten.html";
|
script = panoptikon.urlSelector "[itemprop=articleBody]" "https://www.indogermanistik.org/aktuelles/neuigkeiten.html";
|
||||||
reporters = [reporters.irc-kmein];
|
reporters = [irc-kmein];
|
||||||
};
|
};
|
||||||
ig-tagungen = {
|
ig-tagungen = {
|
||||||
script = urlSelector "[itemprop=articleBody]" "https://www.indogermanistik.org/tagungen/tagungen-der-ig.html";
|
script = panoptikon.urlSelector "[itemprop=articleBody]" "https://www.indogermanistik.org/tagungen/tagungen-der-ig.html";
|
||||||
reporters = [reporters.irc-kmein];
|
reporters = [irc-kmein];
|
||||||
};
|
};
|
||||||
fxght-or-flxght = {
|
fxght-or-flxght = {
|
||||||
script = pkgs.writers.writeDash "watch-url-json" ''
|
script = panoptikon.urlJSON {
|
||||||
${pkgs.curl}/bin/curl -sSL 'https://api.tellonym.me/profiles/name/fxght.or.flxght?limit=20' \
|
jqScript = ''
|
||||||
| ${pkgs.jq}/bin/jq '.answers | map(
|
.answers | map(
|
||||||
select(.type == "answer")
|
select(.type == "answer")
|
||||||
| {
|
| {
|
||||||
question: .tell,
|
question: .tell,
|
||||||
answer: .answer,
|
answer: .answer,
|
||||||
date: .createdAt,
|
date: .createdAt,
|
||||||
media: .media | map(.url)
|
media: .media | map(.url)
|
||||||
}
|
}
|
||||||
)'
|
)
|
||||||
'';
|
'';
|
||||||
reporters = [reporters.irc-kmein];
|
} "https://api.tellonym.me/profiles/name/fxght.or.flxght?limit=20";
|
||||||
|
reporters = [irc-kmein];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user