Merge remote-tracking branch 'lass/master'

This commit is contained in:
makefu 2022-03-10 23:38:36 +01:00
commit 7684bcb3d4
No known key found for this signature in database
GPG Key ID: 36F7711F3FC0F225
9 changed files with 76 additions and 22 deletions

View File

@ -184,7 +184,7 @@
exit 1 exit 1
fi fi
twitter_nick=$(echo "$1" | ${pkgs.jq}/bin/jq -Rr '[match("(\\S+)\\s*";"g").captures[].string][0]') 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" '' search.filename = pkgs.writeDash "search" ''
set -euf set -euf

View File

@ -63,6 +63,7 @@ in
"names.kmein.r" "names.kmein.r"
"graph.r" "graph.r"
"rrm.r" "rrm.r"
"redaktion.r"
]; ];
ip4.addr = "10.243.2.84"; ip4.addr = "10.243.2.84";
tinc.pubkey = '' tinc.pubkey = ''

View File

@ -19,13 +19,15 @@ with import <stockholm/lib>;
"hosts" = tinc.config.hostsPackage; "hosts" = tinc.config.hostsPackage;
"tinc.conf" = pkgs.writeText "${netname}-tinc.conf" '' "tinc.conf" = pkgs.writeText "${netname}-tinc.conf" ''
Name = ${tinc.config.host.name} Name = ${tinc.config.host.name}
LogLevel = ${toString tinc.config.logLevel}
Interface = ${netname} Interface = ${netname}
Broadcast = no Broadcast = no
${concatMapStrings (c: "ConnectTo = ${c}\n") tinc.config.connectTo} ${concatMapStrings (c: "ConnectTo = ${c}\n") tinc.config.connectTo}
Port = ${toString tinc.config.host.nets.${netname}.tinc.port} Port = ${toString tinc.config.host.nets.${netname}.tinc.port}
${tinc.config.extraConfig} ${tinc.config.extraConfig}
''; '';
"tinc-up" = pkgs.writeDash "${netname}-tinc-up" '' "tinc-up" = pkgs.writeScript "${netname}-tinc-up" ''
#!/bin/sh
ip link set ${netname} up ip link set ${netname} up
${tinc.config.tincUp} ${tinc.config.tincUp}
''; '';
@ -192,6 +194,14 @@ with import <stockholm/lib>;
''; '';
}; };
logLevel = mkOption {
type = types.int;
description = ''
LogLevel in tinc.conf
'';
default = 3;
};
user = mkOption { user = mkOption {
type = types.user; type = types.user;
default = { default = {

View File

@ -1,9 +1,9 @@
{ {
"url": "https://github.com/NixOS/nixpkgs", "url": "https://github.com/NixOS/nixpkgs",
"rev": "60c52a73f1d5858020ac4f161cd5bf1c9650f8b8", "rev": "7f9b6e2babf232412682c09e57ed666d8f84ac2d",
"date": "2022-02-07T23:59:33+00:00", "date": "2022-02-21T09:47:16+01:00",
"path": "/nix/store/5w1yn77d2b44wq0w7b8cqqqfap2897n2-nixpkgs", "path": "/nix/store/4vd9z4b2s4jfn96ypdfavizy6908l71h-nixpkgs",
"sha256": "1xyi4xag084ikcbis3iixpvfsmlfm2s105j58770x7k24mkrif7n", "sha256": "03nb8sbzgc3c0qdr1jbsn852zi3qp74z4qcy7vrabvvly8rbixp2",
"fetchLFS": false, "fetchLFS": false,
"fetchSubmodules": false, "fetchSubmodules": false,
"deepClone": false, "deepClone": false,

View File

@ -1,9 +1,9 @@
{ {
"url": "https://github.com/NixOS/nixpkgs", "url": "https://github.com/NixOS/nixpkgs",
"rev": "521e4d7d13b09bc0a21976b9d19abd197d4e3b1e", "rev": "47cd6702934434dd02bc53a67dbce3e5493e33a2",
"date": "2022-02-07T00:29:53+00:00", "date": "2022-03-04T16:09:08+01:00",
"path": "/nix/store/pvmrsiy8k37nwg18g7230g5kasbsf132-nixpkgs", "path": "/nix/store/xbb640k873m7nmchdrnijl0f9n540ys6-nixpkgs",
"sha256": "156b4wnm6y6lg0gz09mp48rd0mhcdazr5s888c4lbhlpn3j8h042", "sha256": "1rvp9gx7n0gppc86bcysaybw79zl3y8yninsgz6rawdjprzvg7y6",
"fetchLFS": false, "fetchLFS": false,
"fetchSubmodules": false, "fetchSubmodules": false,
"deepClone": false, "deepClone": false,

View File

@ -66,4 +66,6 @@
enable = true; enable = true;
client.enable = true; client.enable = true;
}; };
documentation.nixos.enable = true;
} }

View File

@ -5,15 +5,6 @@ let
in { in {
users.extraUsers = { users.extraUsers = {
bch = {
name = "bch";
description = "user for bch stuff";
home = "/home/bch";
useDefaultShell = true;
createHome = true;
packages = [ pkgs.electron-cash ];
isNormalUser = true;
};
bitcoin = { bitcoin = {
name = "bitcoin"; name = "bitcoin";
description = "user for bitcoin stuff"; description = "user for bitcoin stuff";

View File

@ -221,4 +221,7 @@ with import <stockholm/lib>;
time.timeZone = mkDefault"Europe/Berlin"; time.timeZone = mkDefault"Europe/Berlin";
system.stateVersion = mkDefault "20.03"; system.stateVersion = mkDefault "20.03";
# disable doc usually
documentation.nixos.enable = mkDefault false;
} }

View File

@ -1,8 +1,8 @@
{ config, pkgs, ... }: with pkgs.stockholm.lib; { config, lib, pkgs, ... }:
let let
weather_report = pkgs.writers.writeDashBin "weather_report" '' weather_report = pkgs.writers.writeDashBin "weather_report" ''
set -efu 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 ' | ${pkgs.jq}/bin/jq -r '
[.nearest_area[0] | "Weather report for \(.areaName[0].value), \(.country[0].value)."] [.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."] + [.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 ${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 */ '' newsshow = pkgs.writers.writeDashBin "newsshow" /* sh */ ''
echo " echo "
hello crabpeople! hello crabpeople!
$(${pkgs.ddate}/bin/ddate | sed 's/YOLD/Year of Discord/')! $(${pkgs.ddate}/bin/ddate | sed 's/YOLD/Year of Discord/')!
It is $(date --utc +%H) o clock UTC. It is $(date --utc +%H) o clock UTC.
todays news:
$(get_current_news)
$(gc_news)
$(weather_report berlin) $(weather_report berlin)
$(weather_report 70173) $(weather_report 70173)
$(weather_report munich) $(weather_report munich)
@ -30,6 +44,8 @@ in
path = [ path = [
newsshow newsshow
send_to_radio send_to_radio
gc_news
get_current_news
weather_report weather_report
pkgs.curl pkgs.curl
pkgs.retry pkgs.retry
@ -37,10 +53,41 @@ in
script = '' script = ''
set -efu set -efu
retry -t 5 -d 10 -- newsshow | 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 retry -t 5 -d 10 -- send_to_radio
''; '';
startAt = "*:00:00"; 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 ## debug