summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--krebs/2configs/news.nix2
-rw-r--r--krebs/3modules/tinc.nix3
-rw-r--r--krebs/nixpkgs-unstable.json8
-rw-r--r--krebs/nixpkgs.json8
-rw-r--r--lass/2configs/bitcoin.nix9
-rw-r--r--lass/2configs/radio-news.nix53
6 files changed, 61 insertions, 22 deletions
diff --git a/krebs/2configs/news.nix b/krebs/2configs/news.nix
index 9ea4cbf8d..1f966bf24 100644
--- a/krebs/2configs/news.nix
+++ b/krebs/2configs/news.nix
@@ -184,7 +184,7 @@
exit 1
fi
twitter_nick=$(echo "$1" | ${pkgs.jq}/bin/jq -Rr '[match("(\\S+)\\s*";"g").captures[].string][0]')
- echo "brockman: add tw_$twitter_nick http://rss.r/?action=display&bridge=Twitch&channel=$twitter_nick&type=all&format=Atom"
+ echo "brockman: add tw_$twitter_nick http://rss.r/?action=display&bridge=Twitter&context=By+username&u=$twitter_nick&norep=on&noretweet=on&nopinned=on&nopic=on&format=Atom"
'';
search.filename = pkgs.writeDash "search" ''
set -euf
diff --git a/krebs/3modules/tinc.nix b/krebs/3modules/tinc.nix
index bc85aa0a6..e9d1b30ae 100644
--- a/krebs/3modules/tinc.nix
+++ b/krebs/3modules/tinc.nix
@@ -25,7 +25,8 @@ with import <stockholm/lib>;
Port = ${toString tinc.config.host.nets.${netname}.tinc.port}
${tinc.config.extraConfig}
'';
- "tinc-up" = pkgs.writeDash "${netname}-tinc-up" ''
+ "tinc-up" = pkgs.writeScript "${netname}-tinc-up" ''
+ #!/bin/sh
ip link set ${netname} up
${tinc.config.tincUp}
'';
diff --git a/krebs/nixpkgs-unstable.json b/krebs/nixpkgs-unstable.json
index 12afe0e9c..71367c2f1 100644
--- a/krebs/nixpkgs-unstable.json
+++ b/krebs/nixpkgs-unstable.json
@@ -1,9 +1,9 @@
{
"url": "https://github.com/NixOS/nixpkgs",
- "rev": "60c52a73f1d5858020ac4f161cd5bf1c9650f8b8",
- "date": "2022-02-07T23:59:33+00:00",
- "path": "/nix/store/5w1yn77d2b44wq0w7b8cqqqfap2897n2-nixpkgs",
- "sha256": "1xyi4xag084ikcbis3iixpvfsmlfm2s105j58770x7k24mkrif7n",
+ "rev": "7f9b6e2babf232412682c09e57ed666d8f84ac2d",
+ "date": "2022-02-21T09:47:16+01:00",
+ "path": "/nix/store/4vd9z4b2s4jfn96ypdfavizy6908l71h-nixpkgs",
+ "sha256": "03nb8sbzgc3c0qdr1jbsn852zi3qp74z4qcy7vrabvvly8rbixp2",
"fetchLFS": false,
"fetchSubmodules": false,
"deepClone": false,
diff --git a/krebs/nixpkgs.json b/krebs/nixpkgs.json
index 22d465b27..c9b40c10f 100644
--- a/krebs/nixpkgs.json
+++ b/krebs/nixpkgs.json
@@ -1,9 +1,9 @@
{
"url": "https://github.com/NixOS/nixpkgs",
- "rev": "521e4d7d13b09bc0a21976b9d19abd197d4e3b1e",
- "date": "2022-02-07T00:29:53+00:00",
- "path": "/nix/store/pvmrsiy8k37nwg18g7230g5kasbsf132-nixpkgs",
- "sha256": "156b4wnm6y6lg0gz09mp48rd0mhcdazr5s888c4lbhlpn3j8h042",
+ "rev": "4275a321beab5a71872fb7a5fe5da511bb2bec73",
+ "date": "2022-02-23T13:42:45-08:00",
+ "path": "/nix/store/g521qhbql6116naa3fjgga6dm0r24ynx-nixpkgs",
+ "sha256": "1p3pn7767ifbg08nmgjd93iqk0z87z4lv29ypalj9idwd3chsm69",
"fetchLFS": false,
"fetchSubmodules": false,
"deepClone": false,
diff --git a/lass/2configs/bitcoin.nix b/lass/2configs/bitcoin.nix
index 9aa97a8ce..de6562cbc 100644
--- a/lass/2configs/bitcoin.nix
+++ b/lass/2configs/bitcoin.nix
@@ -5,15 +5,6 @@ let
in {
users.extraUsers = {
- bch = {
- name = "bch";
- description = "user for bch stuff";
- home = "/home/bch";
- useDefaultShell = true;
- createHome = true;
- packages = [ pkgs.electron-cash ];
- isNormalUser = true;
- };
bitcoin = {
name = "bitcoin";
description = "user for bitcoin stuff";
diff --git a/lass/2configs/radio-news.nix b/lass/2configs/radio-news.nix
index a4e28c1b1..eb7d3bd9a 100644
--- a/lass/2configs/radio-news.nix
+++ b/lass/2configs/radio-news.nix
@@ -1,8 +1,8 @@
-{ config, pkgs, ... }: with pkgs.stockholm.lib;
+{ config, lib, pkgs, ... }:
let
weather_report = pkgs.writers.writeDashBin "weather_report" ''
set -efu
- ${pkgs.curl}/bin/curl -sSL https://wttr.in/''${1-}?format=j1 \
+ ${pkgs.curl}/bin/curl -fsSL https://wttr.in/''${1-}?format=j1 \
| ${pkgs.jq}/bin/jq -r '
[.nearest_area[0] | "Weather report for \(.areaName[0].value), \(.country[0].value)."]
+ [.current_condition[0] | "Currently it is \(.weatherDesc[0].value) outside with a temperature of \(.temp_C) degrees."]
@@ -14,11 +14,25 @@ let
${pkgs.libshout}/bin/shout --format ogg --host localhost --port 1338 --mount /live
'';
+ gc_news = pkgs.writers.writeDashBin "gc_news" ''
+ set -xefu
+ ${pkgs.coreutils}/bin/cat $HOME/news | ${pkgs.jq}/bin/jq -cs 'map(select((.to|fromdateiso8601) > now)) | .[]' > $HOME/bla-news.tmp
+ ${pkgs.coreutils}/bin/mv $HOME/bla-news.tmp $HOME/news
+ '';
+
+ get_current_news = pkgs.writers.writeDashBin "get_current_news" ''
+ set -xefu
+ ${pkgs.coreutils}/bin/cat $HOME/news | ${pkgs.jq}/bin/jq -rs 'map(select(((.to | fromdateiso8601) > now) and (.from|fromdateiso8601) < now) | .text) | .[]'
+ '';
+
newsshow = pkgs.writers.writeDashBin "newsshow" /* sh */ ''
echo "
hello crabpeople!
$(${pkgs.ddate}/bin/ddate | sed 's/YOLD/Year of Discord/')!
It is $(date --utc +%H) o clock UTC.
+ todays news:
+ $(get_current_news)
+ $(gc_news)
$(weather_report berlin)
$(weather_report 70173)
$(weather_report munich)
@@ -30,6 +44,8 @@ in
path = [
newsshow
send_to_radio
+ gc_news
+ get_current_news
weather_report
pkgs.curl
pkgs.retry
@@ -37,10 +53,41 @@ in
script = ''
set -efu
retry -t 5 -d 10 -- newsshow |
- retry -t 5 -d 10 -- curl -SsG http://tts.r/api/tts --data-urlencode 'text@-' |
+ retry -t 5 -d 10 -- curl -fSsG http://tts.r/api/tts --data-urlencode 'text@-' |
retry -t 5 -d 10 -- send_to_radio
'';
startAt = "*:00:00";
+ serviceConfig = {
+ User = "radio-news";
+ };
+ };
+
+ krebs.iptables.tables.filter.INPUT.rules = [
+ { predicate = "-p tcp --dport 7999"; target = "ACCEPT"; }
+ ];
+
+ krebs.htgen.news = {
+ port = 7999;
+ user = {
+ name = "radio-news";
+ };
+ script = ''. ${pkgs.writers.writeDash "htgen-news" ''
+ set -xefu
+ case "$Method $Request_URI" in
+ "POST /")
+ payload=$(head -c "$req_content_length" \
+ | sed 's/+/ /g;s/%\(..\)/\\x\1/g;' \
+ | xargs -0 echo -e \
+ )
+ echo "$payload" | jq 'has("from") and has("to") and has("text")' >&2
+ echo "$payload" | jq -c '{ from: (.from | fromdate | todate), to: (.to | fromdate | todate), text: .text }' >> $HOME/news
+ printf 'HTTP/1.1 200 OK\r\n'
+ printf 'Connection: close\r\n'
+ printf '\r\n'
+ exit
+ ;;
+ esac
+ ''}'';
};
## debug