diff --git a/configs/meddl.nix b/configs/meddl.nix new file mode 100644 index 0000000..497d90d --- /dev/null +++ b/configs/meddl.nix @@ -0,0 +1,61 @@ +{ pkgs, config, ... }: +let + meddlPort = 8000; +in +{ + containers.meddl = { + autoStart = true; + config = {config, pkgs, ...}: { + environment.systemPackages = [ pkgs.mpc_cli ]; + systemd.services.meddl = { + before = [ "mpd.service" ]; + wantedBy = [ "mpd.service" ]; + startAt = "*:00/10"; + script = '' + set -efu + host=http://antenne-asb.ga + + prepend_host() { + sed "s#^#$host/#" + } + + ${pkgs.curl}/bin/curl -sSL "$host" \ + | ${pkgs.pup}/bin/pup 'li a attr{href}' \ + | prepend_host \ + | while read -r song; do + song_url="$(${pkgs.curl}/bin/curl -sSL "$song" \ + | ${pkgs.pup}/bin/pup 'audio source attr{src}' \ + | prepend_host + )" + ${pkgs.mpc_cli}/bin/mpc add "$song_url" + done + + ${pkgs.mpc_cli}/bin/mpc play + ''; + }; + services.mpd = { + enable = true; + extraConfig = '' + log_level "default" + volume_normalization "yes" + + audio_output { + name "DrachenLord Radio" + type "httpd" + encoder "vorbis" + port "${toString meddlPort}" + bitrate "128" + format "44100:16:2" + always_on "yes" + tags "yes" + } + ''; + }; + + }; + }; + + services.nginx.virtualHosts."makanek.r".locations = { + "= /meddl.ogg".proxyPass = "http://127.0.0.1:${toString meddlPort}"; + }; +} diff --git a/configs/mpd.nix b/configs/mpd.nix index b5bca02..9b66ae4 100644 --- a/configs/mpd.nix +++ b/configs/mpd.nix @@ -39,7 +39,8 @@ in services.mpd-fm = { enable = true; - stationsFile = "/etc/mpd-fm/stations.json"; + # stationsFile = "/etc/mpd-fm/stations.json"; + stations = lib.lists.imap0 (id: {desc ? "", logo ? "https://picsum.photos/seed/${builtins.hashString "md5" stream}/300", stream, station}: { inherit id desc logo stream station; }) streams; webPort = 8080; }; @@ -70,7 +71,7 @@ in recommendedTlsSettings = true; virtualHosts.default = { basicAuth.dj = lib.strings.fileContents ; - locations."~ ^/listen" = { + locations."= /listen.ogg" = { proxyPass = "http://127.0.0.1:${toString multi-room-audio-port}"; }; locations."/" = { diff --git a/lib/streams.nix b/lib/streams.nix index 53e4173..f85d483 100644 --- a/lib/streams.nix +++ b/lib/streams.nix @@ -35,7 +35,7 @@ in [ desc = "Diminutive from lassus (“weary, faint, tired”). A programming human. Doing superior professional art."; } { - stream = "ANTENNE_ASB_URL"; + stream = "http://makanek.r/meddl.ogg"; station = "Antenne ASB"; logo = "https://antenne-asb.ga/logo.png"; desc = "Nonstop Drachenlord Radio – Hier wird nicht nur, aber auch Meddl gespielt."; diff --git a/systems/makanek/configuration.nix b/systems/makanek/configuration.nix index 6607b4a..92bc9b6 100644 --- a/systems/makanek/configuration.nix +++ b/systems/makanek/configuration.nix @@ -11,6 +11,7 @@ in +