summaryrefslogtreecommitdiffstats
path: root/lass
diff options
context:
space:
mode:
Diffstat (limited to 'lass')
-rw-r--r--lass/1systems/prism/config.nix1
-rw-r--r--lass/2configs/hass/default.nix13
-rw-r--r--lass/2configs/radio-news.nix52
-rw-r--r--lass/2configs/radio.nix60
4 files changed, 91 insertions, 35 deletions
diff --git a/lass/1systems/prism/config.nix b/lass/1systems/prism/config.nix
index a082ea623..c62091428 100644
--- a/lass/1systems/prism/config.nix
+++ b/lass/1systems/prism/config.nix
@@ -114,6 +114,7 @@ with import <stockholm/lib>;
<stockholm/lass/2configs/exim-smarthost.nix>
<stockholm/lass/2configs/privoxy-retiolum.nix>
<stockholm/lass/2configs/radio.nix>
+ <stockholm/lass/2configs/radio-news.nix>
<stockholm/lass/2configs/binary-cache/server.nix>
<stockholm/lass/2configs/iodined.nix>
<stockholm/lass/2configs/paste.nix>
diff --git a/lass/2configs/hass/default.nix b/lass/2configs/hass/default.nix
index 4ed0bfa5f..8f93e0cec 100644
--- a/lass/2configs/hass/default.nix
+++ b/lass/2configs/hass/default.nix
@@ -1,12 +1,6 @@
{ config, lib, pkgs, ... }:
with import ./lib.nix { inherit lib; };
let
- unstable = import (pkgs.fetchFromGitHub {
- owner = "nixos";
- repo = "nixpkgs";
- rev = (lib.importJSON ../../../krebs/nixpkgs-unstable.json).rev;
- sha256 = (lib.importJSON ../../../krebs/nixpkgs-unstable.json).sha256;
- }) {};
dwdwfsapi = pkgs.python3Packages.buildPythonPackage rec {
pname = "dwdwfsapi";
version = "1.0.3";
@@ -35,17 +29,14 @@ in {
{ predicate = "-i int0 -p tcp --dport 1883"; target = "ACCEPT"; } # mosquitto
{ predicate = "-i docker0 -p tcp --dport 1883"; target = "ACCEPT"; } # mosquitto
{ predicate = "-i int0 -p tcp --dport 8123"; target = "ACCEPT"; } # hass
- { predicate = "-i int0 -p tcp --dport 1337"; target = "ACCEPT"; } # hass
+ { predicate = "-i int0 -p tcp --dport 1337"; target = "ACCEPT"; } # zigbee2mqtt frontend
{ predicate = "-i retiolum -p tcp --dport 8123"; target = "ACCEPT"; } # hass
- { predicate = "-i retiolum -p tcp --dport 1337"; target = "ACCEPT"; } # hass frontend
+ { predicate = "-i retiolum -p tcp --dport 1337"; target = "ACCEPT"; } # zigbee2mqtt frontend
{ predicate = "-i wiregrill -p tcp --dport 8123"; target = "ACCEPT"; } # hass
];
services.home-assistant = {
enable = true;
- package = unstable.home-assistant.overrideAttrs (old: {
- doInstallCheck = false;
- });
configWritable = true;
lovelaceConfigWritable = true;
config = let
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
+ # ];
+}
diff --git a/lass/2configs/radio.nix b/lass/2configs/radio.nix
index 501251d13..15d07dada 100644
--- a/lass/2configs/radio.nix
+++ b/lass/2configs/radio.nix
@@ -1,6 +1,5 @@
{ config, pkgs, ... }:
-
-with import <stockholm/lib>;
+with pkgs.stockholm.lib;
let
name = "radio";
@@ -84,7 +83,7 @@ let
'';
set_irc_topic = pkgs.writeDash "set_irc_topic" ''
- ${pkgs.curl}/bin/curl -fsSv --unix-socket /home/radio/reaktor.sock http://z/ \
+ ${pkgs.curl}/bin/curl -fsS --unix-socket /home/radio/reaktor.sock http://z/ \
-H content-type:application/json \
-d "$(${pkgs.jq}/bin/jq -n \
--arg text "$1" '{
@@ -109,12 +108,12 @@ in {
users.users = {
"${name}" = rec {
inherit name;
+ createHome = mkForce false;
group = name;
uid = genid_uint31 name;
description = "radio manager";
home = "/home/${name}";
useDefaultShell = true;
- createHome = true;
openssh.authorizedKeys.keys = with config.krebs.users; [
lass.pubkey
lass-mors.pubkey
@@ -148,27 +147,37 @@ in {
audio_output {
type "httpd"
- name "lassulus radio mp3"
- encoder "lame" # optional
- port "8002"
- quality "5.0" # do not define if bitrate is defined
- # bitrate "128" # do not define if quality is defined
+ name "raw radio"
+ encoder "wave"
+ port "7900"
format "44100:16:2"
always_on "yes" # prevent MPD from disconnecting all listeners when playback is stopped.
tags "yes" # httpd supports sending tags to listening streams.
}
+ '';
+ };
+ services.liquidsoap.streams.radio-news = pkgs.writeText "radio-news.liq" ''
+ source = mksafe(input.http("http://localhost:7900/raw.wave"))
- audio_output {
- type "httpd"
- name "lassulus radio"
- encoder "vorbis" # optional
- port "8000"
- quality "5.0" # do not define if bitrate is defined
- # bitrate "128" # do not define if quality is defined
- format "44100:16:2"
- always_on "yes" # prevent MPD from disconnecting all listeners when playback is stopped.
- tags "yes" # httpd supports sending tags to listening streams.
- }
+ output.icecast(mount = '/music.ogg', password = 'hackme', %vorbis(quality = 1), source)
+ output.icecast(mount = '/music.mp3', password = 'hackme', %mp3.vbr(), source)
+ output.icecast(mount = '/music.opus', password = 'hackme', %opus(), source)
+
+ extra_input = audio_to_stereo(input.harbor("live", port=1338))
+
+ o = smooth_add(normal = source, special = extra_input)
+ output.icecast(mount = '/radio.ogg', password = 'hackme', %vorbis(quality = 1), o)
+ output.icecast(mount = '/radio.mp3', password = 'hackme', %mp3.vbr(), o)
+ output.icecast(mount = '/radio.opus', password = 'hackme', %opus(), o)
+ '';
+ services.icecast = {
+ enable = true;
+ hostname = "radio.lassul.us";
+ admin.password = "hackme";
+ extraConf = ''
+ <authentication>
+ <source-password>hackme</source-password>
+ </authentication>
'';
};
@@ -176,7 +185,6 @@ in {
tables = {
filter.INPUT.rules = [
{ predicate = "-p tcp --dport 8000"; target = "ACCEPT"; }
- { predicate = "-p tcp --dport 8002"; target = "ACCEPT"; }
{ predicate = "-i retiolum -p tcp --dport 8001"; target = "ACCEPT"; }
];
};
@@ -219,13 +227,16 @@ in {
systemd.services.radio-recent = let
recentlyPlayed = pkgs.writeDash "recentlyPlayed" ''
+ set -xeu
LIMIT=1000 #how many tracks to keep in the history
- HISTORY_FILE=/tmp/played
+ HISTORY_FILE=/var/lib/radio/recent
while :; do
${pkgs.mpc_cli}/bin/mpc idle player > /dev/null
${pkgs.mpc_cli}/bin/mpc current -f %file%
done | while read track; do
- listeners=$(${pkgs.iproute}/bin/ss -Hno state established 'sport = :8000' | grep '^tcp' | wc -l)
+
+ listeners=$(${pkgs.curl}/bin/curl lassul.us:8000/status-json.xsl |
+ ${pkgs.jq}/bin/jq '[.icestats.source[].listeners] | add')
echo "$(date -Is)" "$track" | tee -a "$HISTORY_FILE"
echo "$(tail -$LIMIT "$HISTORY_FILE")" > "$HISTORY_FILE"
${set_irc_topic} "playing: $track listeners: $listeners"
@@ -345,7 +356,8 @@ in {
proxy_pass http://localhost:8000;
'';
locations."= /recent".extraConfig = ''
- alias /tmp/played;
+ default_type "text/plain";
+ alias /var/lib/radio/recent;
'';
locations."= /current".extraConfig = ''
proxy_pass http://localhost:8001;