From a374a452112ba962ab90e45b6b0f27b3a1330e4f Mon Sep 17 00:00:00 2001 From: lassulus Date: Tue, 25 Sep 2018 14:53:53 +0200 Subject: l radio: show recent tracks at https://radio.lassul.us/recent --- lass/2configs/radio.nix | 81 +++++++++++++++++++++++++++++++++++-------------- 1 file changed, 59 insertions(+), 22 deletions(-) diff --git a/lass/2configs/radio.nix b/lass/2configs/radio.nix index a83d51f1d..fb7ae01b6 100644 --- a/lass/2configs/radio.nix +++ b/lass/2configs/radio.nix @@ -131,6 +131,30 @@ in { }; }; + systemd.services.radio-recent = let + recentlyPlayed = pkgs.writeDash "recentlyPlayed" '' + LIMIT=1000 #how many tracks to keep in the history + HISTORY_FILE=/tmp/played + while :; do + ${pkgs.mpc_cli}/bin/mpc idle player > /dev/null + ${pkgs.mpc_cli}/bin/mpc current -f %file% + done | while read track; do + echo "$(date -Is)" "$track" | tee -a "$HISTORY_FILE" + echo "$(tail -$LIMIT "$HISTORY_FILE")" > "$HISTORY_FILE" + done + ''; + in { + description = "radio recently played"; + after = [ "mpd.service" "network.target" ]; + wantedBy = [ "multi-user.target" ]; + + restartIfChanged = true; + + serviceConfig = { + ExecStart = recentlyPlayed; + }; + }; + krebs.Reaktor.playlist = { nickname = "the_playlist|r"; channels = [ @@ -157,27 +181,40 @@ in { }) ]; }; - services.nginx.virtualHosts."lassul.us".locations."/the_playlist".extraConfig = let - html = pkgs.writeText "index.html" '' - - - - - lassulus playlist - - -
- -
-
- -
- - - + services.nginx = { + enable = true; + virtualHosts."radio.lassul.us" = { + forceSSL = true; + enableACME = true; + locations."/".extraConfig = '' + proxy_pass http://localhost:8000; + ''; + locations."/recent".extraConfig = '' + alias /tmp/played; + ''; + }; + virtualHosts."lassul.us".locations."/the_playlist".extraConfig = let + html = pkgs.writeText "index.html" '' + + + + + lassulus playlist + + +
+ +
+
+ +
+ + + + ''; + in '' + default_type "text/html"; + alias ${html}; ''; - in '' - default_type "text/html"; - alias ${html}; - ''; + }; } -- cgit v1.2.3