diff options
Diffstat (limited to 'lass')
-rw-r--r-- | lass/1systems/mors/config.nix | 1 | ||||
-rw-r--r-- | lass/1systems/prism/config.nix | 1 | ||||
-rw-r--r-- | lass/2configs/fysiirc.nix | 42 | ||||
-rw-r--r-- | lass/2configs/hass/default.nix | 13 | ||||
-rw-r--r-- | lass/2configs/hass/zigbee.nix | 2 | ||||
-rw-r--r-- | lass/2configs/murmur.nix | 6 | ||||
-rw-r--r-- | lass/2configs/radio-news.nix | 52 | ||||
-rw-r--r-- | lass/2configs/radio.nix | 60 | ||||
-rw-r--r-- | lass/2configs/retiolum.nix | 8 | ||||
-rw-r--r-- | lass/2configs/sync/decsync.nix | 2 | ||||
-rw-r--r-- | lass/2configs/sync/sync.nix | 2 | ||||
-rw-r--r-- | lass/2configs/sync/the_playlist.nix | 9 | ||||
-rw-r--r-- | lass/2configs/sync/weechat.nix | 2 |
13 files changed, 147 insertions, 53 deletions
diff --git a/lass/1systems/mors/config.nix b/lass/1systems/mors/config.nix index 4d042de22..dd479f267 100644 --- a/lass/1systems/mors/config.nix +++ b/lass/1systems/mors/config.nix @@ -26,6 +26,7 @@ with import <stockholm/lib>; <stockholm/lass/2configs/sync/sync.nix> <stockholm/lass/2configs/sync/decsync.nix> <stockholm/lass/2configs/sync/weechat.nix> + <stockholm/lass/2configs/sync/the_playlist.nix> #<stockholm/lass/2configs/c-base.nix> <stockholm/lass/2configs/br.nix> <stockholm/lass/2configs/ableton.nix> 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/fysiirc.nix b/lass/2configs/fysiirc.nix index d2aaa73c5..f3c1d5b7c 100644 --- a/lass/2configs/fysiirc.nix +++ b/lass/2configs/fysiirc.nix @@ -1,5 +1,33 @@ -{ config, lib, pkgs, ... }: -{ +{ config, lib, pkgs, ... }: let + + format-github-message = pkgs.writeDashBin "format-github-message" '' + set -xefu + export PATH=${lib.makeBinPath [ + pkgs.jq + ]} + INPUT=$(jq -c .) + if $(echo "$INPUT" | jq 'has("issue") or has("pull_request")'); then + ${write_to_irc} "$(echo "$INPUT" | jq -r ' + "\(.action): " + + "[\(.issue.title // .pull_request.title)] " + + "\(.comment.html_url // .issue.html_url // .pull_request.html_url) " + + "by \(.comment.user.login // .issue.user.login // .pull_request.user.login)" + ')" + fi + ''; + + write_to_irc = pkgs.writeDash "write_to_irc" '' + ${pkgs.curl}/bin/curl -fsSv http://localhost:44001 \ + -H content-type:application/json \ + -d "$(${pkgs.jq}/bin/jq -n \ + --arg text "$1" '{ + command:"PRIVMSG", + params:["#fysi",$text] + }' + )" + ''; + +in { krebs.iptables.tables.filter.INPUT.rules = [ { predicate = "-p tcp --dport 44002"; target = "ACCEPT"; } ]; @@ -26,20 +54,14 @@ name = "reaktor2-fysiweb-github"; }; script = ''. ${pkgs.writeDash "github-irc" '' + set -efu case "$Method $Request_URI" in "POST /") payload=$(head -c "$req_content_length" \ | sed 's/+/ /g;s/%\(..\)/\\x\1/g;' \ | xargs -0 echo -e \ ) - ${pkgs.curl}/bin/curl -fsSv http://localhost:44001/ \ - -H content-type:application/json \ - -d "$(echo "$payload" | ${pkgs.jq}/bin/jq \ - '{ - command:"PRIVMSG", - params:["#fysi", "\(.action): \(.comment.html_url // .issue.html_url // .pull_request.html_url)"] - }' - )" + echo "$payload" | ${format-github-message}/bin/format-github-message printf 'HTTP/1.1 200 OK\r\n' printf 'Connection: close\r\n' printf '\r\n' 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/hass/zigbee.nix b/lass/2configs/hass/zigbee.nix index 789a7fb92..8fc02263b 100644 --- a/lass/2configs/hass/zigbee.nix +++ b/lass/2configs/hass/zigbee.nix @@ -15,7 +15,7 @@ in { services.zigbee2mqtt = { enable = true; package = unstable-pkgs.zigbee2mqtt; - config = { + settings = { homeassistant = true; frontend.port = 1337; experimental.new_api = true; diff --git a/lass/2configs/murmur.nix b/lass/2configs/murmur.nix index 7cc4051a8..42670dfbb 100644 --- a/lass/2configs/murmur.nix +++ b/lass/2configs/murmur.nix @@ -2,10 +2,16 @@ { services.murmur = { enable = true; + allowHtml = false; bandwidth = 10000000; registerName = "lassul.us"; autobanTime = 30; + sslCert = "/var/lib/acme/lassul.us/cert.pem"; + sslKey = "/var/lib/acme/lassul.us/key.pem"; }; + users.groups.lasscert.members = [ + "murmur" + ]; krebs.iptables.tables.filter.INPUT.rules = [ { predicate = "-p tcp --dport 64738"; target = "ACCEPT";} { predicate = "-p udp --dport 64738"; target = "ACCEPT";} 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; diff --git a/lass/2configs/retiolum.nix b/lass/2configs/retiolum.nix index 2ddfbcf8f..d4d97a889 100644 --- a/lass/2configs/retiolum.nix +++ b/lass/2configs/retiolum.nix @@ -1,4 +1,4 @@ -{ config, pkgs, ... }: +{ config, lib, pkgs, ... }: { @@ -22,12 +22,12 @@ ]; extraConfig = '' StrictSubnets = yes + ${lib.optionalString (config.krebs.build.host.nets.retiolum.via != null) '' + LocalDiscovery = no + ''} ''; }; - # never connect via gum (he eats our packets!) - krebs.hosts.gum.nets.retiolum.tinc.weight = 9000; - nixpkgs.config.packageOverrides = pkgs: { tinc = pkgs.tinc_pre; }; diff --git a/lass/2configs/sync/decsync.nix b/lass/2configs/sync/decsync.nix index 9caefdd2d..a38cff8d6 100644 --- a/lass/2configs/sync/decsync.nix +++ b/lass/2configs/sync/decsync.nix @@ -1,5 +1,5 @@ { - services.syncthing.declarative.folders.decsync = { + services.syncthing.folders.decsync = { path = "/home/lass/decsync"; devices = [ "mors" "blue" "green" "phone" ]; }; diff --git a/lass/2configs/sync/sync.nix b/lass/2configs/sync/sync.nix index 7c0f2e030..a0927c199 100644 --- a/lass/2configs/sync/sync.nix +++ b/lass/2configs/sync/sync.nix @@ -1,5 +1,5 @@ { - services.syncthing.declarative.folders."/home/lass/sync" = { + services.syncthing.folders."/home/lass/sync" = { devices = [ "mors" "icarus" "xerxes" "shodan" "green" "blue" "coaxmetal" ]; }; krebs.permown."/home/lass/sync" = { diff --git a/lass/2configs/sync/the_playlist.nix b/lass/2configs/sync/the_playlist.nix new file mode 100644 index 000000000..c01a11cc3 --- /dev/null +++ b/lass/2configs/sync/the_playlist.nix @@ -0,0 +1,9 @@ +{ + services.syncthing.folders.the_playlist = { + path = "/home/lass/tmp/the_playlist"; + devices = [ "mors" "phone" "prism" "omo" ]; + }; + krebs.acl."/home/lass/tmp/the_playlist"."u:syncthing:X".parents = true; + krebs.acl."/home/lass/tmp/the_playlist"."u:syncthing:rwX" = {}; + krebs.acl."/home/lass/tmp/the_playlist"."u:lass:rwX" = {}; +} diff --git a/lass/2configs/sync/weechat.nix b/lass/2configs/sync/weechat.nix index 7970f3081..eb6b0aa16 100644 --- a/lass/2configs/sync/weechat.nix +++ b/lass/2configs/sync/weechat.nix @@ -1,5 +1,5 @@ { - services.syncthing.declarative.folders."/home/lass/.weechat".devices = [ "green" "mors" ]; + services.syncthing.folders."/home/lass/.weechat".devices = [ "green" "mors" ]; krebs.permown."/home/lass/.weechat" = { owner = "lass"; group = "syncthing"; |