mirror of
https://github.com/kmein/niveum
synced 2026-03-19 03:21:10 +01:00
feat(zaatar): stream mpd via http, proxy control panel and stream via nginx
This commit is contained in:
@@ -3,11 +3,39 @@ let
|
|||||||
streams = import <niveum/lib/streams.nix> {
|
streams = import <niveum/lib/streams.nix> {
|
||||||
di-fm-key = lib.strings.fileContents <secrets/di.fm/key>;
|
di-fm-key = lib.strings.fileContents <secrets/di.fm/key>;
|
||||||
};
|
};
|
||||||
|
multi-room-audio-port = 8000;
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
imports = [ <niveum/modules/mpd-fm.nix> ];
|
imports = [
|
||||||
|
<niveum/modules/mpd-fm.nix>
|
||||||
|
];
|
||||||
|
|
||||||
environment.systemPackages = [ pkgs.ncmpcpp pkgs.mpc_cli ];
|
services.mpd = {
|
||||||
|
enable = true;
|
||||||
|
extraConfig = ''
|
||||||
|
log_level "default"
|
||||||
|
auto_update "yes"
|
||||||
|
|
||||||
|
audio_output {
|
||||||
|
type "alsa"
|
||||||
|
name "zaatar single room audio system"
|
||||||
|
}
|
||||||
|
|
||||||
|
audio_output {
|
||||||
|
type "httpd"
|
||||||
|
name "zaatar multi room audio system"
|
||||||
|
encoder "vorbis" # optional
|
||||||
|
port "${toString multi-room-audio-port}"
|
||||||
|
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.
|
||||||
|
}
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
environment.systemPackages = [ pkgs.mpc_cli ];
|
||||||
|
|
||||||
services.mpd-fm = {
|
services.mpd-fm = {
|
||||||
enable = true;
|
enable = true;
|
||||||
@@ -15,7 +43,7 @@ in
|
|||||||
webPort = 8080;
|
webPort = 8080;
|
||||||
};
|
};
|
||||||
|
|
||||||
systemd.services.antenne-asb =
|
systemd.services.mpd-fm-stations =
|
||||||
let
|
let
|
||||||
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;
|
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;
|
||||||
stationsJson = pkgs.writeText "stations.json" (builtins.toJSON stations);
|
stationsJson = pkgs.writeText "stations.json" (builtins.toJSON stations);
|
||||||
@@ -33,44 +61,22 @@ in
|
|||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
services.mpd.enable = true;
|
networking.firewall.allowedTCPPorts = [ 80 ];
|
||||||
|
|
||||||
services.nginx = {
|
services.nginx = {
|
||||||
upstreams."mpd-fm-socket" = {
|
enable = true;
|
||||||
extraConfig = ''
|
recommendedGzipSettings = true;
|
||||||
server 127.0.0.1:${toString config.services.mpd-fm.webPort};
|
recommendedOptimisation = true;
|
||||||
'';
|
recommendedProxySettings = true;
|
||||||
};
|
recommendedTlsSettings = true;
|
||||||
appendHttpConfig = ''
|
|
||||||
map $http_upgrade $connection_upgrade {
|
|
||||||
default upgrade;
|
|
||||||
''' close;
|
|
||||||
}
|
|
||||||
'';
|
|
||||||
virtualHosts.default = {
|
virtualHosts.default = {
|
||||||
basicAuth.dj = lib.strings.fileContents <system-secrets/mpd-web.key>;
|
basicAuth.dj = lib.strings.fileContents <system-secrets/mpd-web.key>;
|
||||||
|
locations."~ ^/listen" = {
|
||||||
|
proxyPass = "http://127.0.0.1:${toString multi-room-audio-port}";
|
||||||
|
};
|
||||||
locations."/" = {
|
locations."/" = {
|
||||||
proxyPass = "http://mpd-fm-socket";
|
proxyPass = "http://127.0.0.1:${toString config.services.mpd-fm.webPort}";
|
||||||
extraConfig = ''
|
proxyWebsockets = true;
|
||||||
proxy_http_version 1.1;
|
|
||||||
proxy_set_header Upgrade $http_upgrade;
|
|
||||||
proxy_set_header Connection "Upgrade";
|
|
||||||
proxy_set_header Host $host;
|
|
||||||
''; # generate password hash with `openssl passwd -apr1`
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
|
||||||
# dont let anyone outside localhost or local network in
|
|
||||||
networking.firewall.extraCommands =
|
|
||||||
let
|
|
||||||
mpd-fm-port = toString config.services.mpd-fm.webPort;
|
|
||||||
in ''
|
|
||||||
${pkgs.iptables}/bin/iptables -A INPUT -p tcp --dport ${mpd-fm-port} -s 192.168.0.0/16 -j ACCEPT
|
|
||||||
${pkgs.iptables}/bin/iptables -A INPUT -p tcp --dport ${mpd-fm-port} -s 10.243.2.4 -j ACCEPT
|
|
||||||
${pkgs.iptables}/bin/iptables -A INPUT -p tcp --dport ${mpd-fm-port} -s 127.0.0.0/8 -j ACCEPT
|
|
||||||
${pkgs.iptables}/bin/iptables -A INPUT -p tcp --dport ${mpd-fm-port} -j DROP
|
|
||||||
'';
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,6 +23,9 @@ let
|
|||||||
radiosai-name = name: "${name} | Radiosai";
|
radiosai-name = name: "${name} | Radiosai";
|
||||||
radiosai = name: "https://stream.sssmediacentre.org/${name}";
|
radiosai = name: "https://stream.sssmediacentre.org/${name}";
|
||||||
|
|
||||||
|
royal-name = name: "${name} | RoyalRadio";
|
||||||
|
royal = name: "http://193.33.170.218:8000/${name}";
|
||||||
|
|
||||||
caster-fm = subdomain: port: "http://${subdomain}.caster.fm:${toString port}/listen.mp3?authn0b0236758bd0e178156d0787327a055d";
|
caster-fm = subdomain: port: "http://${subdomain}.caster.fm:${toString port}/listen.mp3?authn0b0236758bd0e178156d0787327a055d";
|
||||||
in [
|
in [
|
||||||
{
|
{
|
||||||
@@ -1001,7 +1004,7 @@ in [
|
|||||||
}
|
}
|
||||||
{
|
{
|
||||||
station = rautemusik-name "Wacken Radio";
|
station = rautemusik-name "Wacken Radio";
|
||||||
desc = "Metal, Heavy MetaL";
|
desc = "Metal, Heavy Metal";
|
||||||
stream = rautemusik "wackenradio";
|
stream = rautemusik "wackenradio";
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
@@ -1303,6 +1306,41 @@ in [
|
|||||||
stream = radiosai "ameri";
|
stream = radiosai "ameri";
|
||||||
desc = "The voice of pure love.";
|
desc = "The voice of pure love.";
|
||||||
}
|
}
|
||||||
|
{
|
||||||
|
stream = royal "RoyalPopsa";
|
||||||
|
station = royal-name "Popsa";
|
||||||
|
desc = "из Санкт-Петербурга";
|
||||||
|
}
|
||||||
|
{
|
||||||
|
stream = royal "RoyalTrance";
|
||||||
|
station = royal-name "Trance";
|
||||||
|
desc = "из Санкт-Петербурга";
|
||||||
|
}
|
||||||
|
{
|
||||||
|
stream = royal "RoyalDrum";
|
||||||
|
station = royal-name "Drum";
|
||||||
|
desc = "из Санкт-Петербурга";
|
||||||
|
}
|
||||||
|
{
|
||||||
|
stream = royal "RoyalTrap";
|
||||||
|
station = royal-name "Trap";
|
||||||
|
desc = "из Санкт-Петербурга";
|
||||||
|
}
|
||||||
|
{
|
||||||
|
stream = royal "RoyalRock";
|
||||||
|
station = royal-name "Rock";
|
||||||
|
desc = "из Санкт-Петербурга";
|
||||||
|
}
|
||||||
|
{
|
||||||
|
stream = royal "RoyalLounge";
|
||||||
|
station = royal-name "Lounge";
|
||||||
|
desc = "из Санкт-Петербурга";
|
||||||
|
}
|
||||||
|
{
|
||||||
|
stream = royal "RoyaLove";
|
||||||
|
station = royal-name "Love";
|
||||||
|
desc = "из Санкт-Петербурга";
|
||||||
|
}
|
||||||
]
|
]
|
||||||
/*
|
/*
|
||||||
(caster-fm "TODO" "noasrv" 10182) # https://github.com/cccruzr/albumsyoumusthear/blob/7e00baf575e4d357cd275d54d1aeb717321141a8/HLS/IBERO_90_1.m3u
|
(caster-fm "TODO" "noasrv" 10182) # https://github.com/cccruzr/albumsyoumusthear/blob/7e00baf575e4d357cd275d54d1aeb717321141a8/HLS/IBERO_90_1.m3u
|
||||||
|
|||||||
@@ -4,8 +4,8 @@ mkYarnPackage rec {
|
|||||||
src = fetchFromGitHub {
|
src = fetchFromGitHub {
|
||||||
owner = "kmein";
|
owner = "kmein";
|
||||||
repo = "MPD.FM";
|
repo = "MPD.FM";
|
||||||
rev = "c7cbaa4ce3b350f26cad54378db22c8ec58d987b";
|
rev = "5f309c2579a9cbbbc4f7eb6a2e2f3993cc177630";
|
||||||
sha256 = "1iklzbaji7ls01jfi1r0frhjq2i1w29kmar7vgw32f5mgj19cyvd";
|
sha256 = "0ladh96s656i7yd9qxrpqq4x513r88zas7112rqn5sgxxaccbh72";
|
||||||
};
|
};
|
||||||
packageJSON = "${src}/package.json";
|
packageJSON = "${src}/package.json";
|
||||||
yarnLock = ./yarn.lock;
|
yarnLock = ./yarn.lock;
|
||||||
|
|||||||
Reference in New Issue
Block a user