diff options
author | makefu <github@syntax-fehler.de> | 2022-02-14 19:48:45 +0100 |
---|---|---|
committer | makefu <github@syntax-fehler.de> | 2022-02-14 19:48:45 +0100 |
commit | a677e709924001ff1b1b591b6011184fb90addd9 (patch) | |
tree | 7aa00fc6012deef486b5e4c154fb51cd6c8e368d /lass/2configs/radio-news.nix | |
parent | bf3c158391b982ed660fd968d4bb2a19590bf5bd (diff) | |
parent | 29dbbbb453bd4fabd91a21f9c3a1f37521b2aec8 (diff) |
Merge remote-tracking branch 'lass/master'
Diffstat (limited to 'lass/2configs/radio-news.nix')
-rw-r--r-- | lass/2configs/radio-news.nix | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/lass/2configs/radio-news.nix b/lass/2configs/radio-news.nix new file mode 100644 index 000000000..a4e28c1b1 --- /dev/null +++ b/lass/2configs/radio-news.nix @@ -0,0 +1,52 @@ +{ config, pkgs, ... }: with pkgs.stockholm.lib; +let + weather_report = pkgs.writers.writeDashBin "weather_report" '' + set -efu + ${pkgs.curl}/bin/curl -sSL 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."] + | join("\n") + ' + ''; + send_to_radio = pkgs.writers.writeDashBin "send_to_radio" '' + ${pkgs.vorbisTools}/bin/oggenc - | + ${pkgs.libshout}/bin/shout --format ogg --host localhost --port 1338 --mount /live + ''; + + 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. + $(weather_report berlin) + $(weather_report 70173) + $(weather_report munich) + " + ''; +in +{ + systemd.services.newsshow = { + path = [ + newsshow + send_to_radio + weather_report + pkgs.curl + pkgs.retry + ]; + 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 -- send_to_radio + ''; + startAt = "*:00:00"; + }; + + ## debug + # environment.systemPackages = [ + # weather_report + # send_to_radio + # newsshow + # ]; +} |