From cc884b94c49ac106289793e31908794d91737e9d Mon Sep 17 00:00:00 2001 From: L-Nafaryus Date: Tue, 5 Nov 2024 16:47:43 +0500 Subject: [PATCH] catarina: new radio station --- .../catarina/services/radio.nix | 88 +++++++++++++++---- 1 file changed, 70 insertions(+), 18 deletions(-) diff --git a/nixosConfigurations/catarina/services/radio.nix b/nixosConfigurations/catarina/services/radio.nix index a59d9f6..b516069 100644 --- a/nixosConfigurations/catarina/services/radio.nix +++ b/nixosConfigurations/catarina/services/radio.nix @@ -1,17 +1,19 @@ {config, ...}: { - containers = { + containers = let + bindMounts = { + "/var/lib/music" = { + hostPath = "/media/storage/audio/library"; + isReadOnly = true; + }; + }; + in { radio-synthwave = { autoStart = true; privateNetwork = true; hostAddress = "10.231.136.1"; localAddress = "10.231.136.2"; - bindMounts = { - "/var/lib/music" = { - hostPath = "/home/l-nafaryus/Music"; - isReadOnly = true; - }; - }; + inherit bindMounts; config = { config, @@ -57,12 +59,7 @@ hostAddress = "10.231.136.1"; localAddress = "10.231.136.3"; - bindMounts = { - "/var/lib/music" = { - hostPath = "/home/l-nafaryus/Music"; - isReadOnly = true; - }; - }; + inherit bindMounts; config = { config, @@ -101,6 +98,52 @@ }; }; }; + + radio-hell-gates = { + autoStart = true; + privateNetwork = true; + hostAddress = "10.231.136.1"; + localAddress = "10.231.136.4"; + + inherit bindMounts; + + config = { + config, + pkgs, + lib, + ... + }: { + services.mpd = { + enable = true; + musicDirectory = "/var/lib/music"; + network.listenAddress = "any"; + #network.startWhenNeeded = true; + user = "mpd"; + network.port = 6602; + extraConfig = '' + audio_output { + type "httpd" + name "Radio" + port "6662" + encoder "lame" + max_clients "0" + website "https://radio.elnafo.ru/hell-gates" + always_on "yes" + tags "yes" + bitrate "128" + format "44100:16:1" + } + ''; + }; + + system.stateVersion = "24.05"; + + networking.firewall = { + enable = true; + allowedTCPPorts = [6602 6662]; + }; + }; + }; }; services.elnafo-radio = { @@ -118,7 +161,7 @@ { id = "synthwave"; name = "Synthwave"; - host = "10.231.136.2"; + host = config.containers.radio-synthwave.localAddress; port = 6600; url = "https://radio.elnafo.ru/synthwave"; status = "Receive"; @@ -127,21 +170,30 @@ { id = "non-stop-pop"; name = "Non-Stop-Pop"; - host = "10.231.136.3"; + host = config.containers.radio-non-stop-pop.localAddress; port = 6601; url = "https://radio.elnafo.ru/non-stop-pop"; status = "Online"; location = "Los Santos"; genre = "pop, r&b, dance music"; } + { + id = "hell-gates"; + name = "Hell Gates"; + host = config.containers.radio-non-stop-pop.localAddress; + port = 6602; + url = "https://radio.elnafo.ru/hell-gates"; + status = "Receive"; + genre = "melodic death metal, death metal, metalcore"; + } ]; }; services.nginx.virtualHosts."radio.elnafo.ru" = { forceSSL = true; useACMEHost = "elnafo.ru"; - locations."/".proxyPass = "http://127.0.0.1:54605"; - locations."/synthwave".proxyPass = "http://10.231.136.2:6660"; - locations."/non-stop-pop".proxyPass = "http://10.231.136.3:6661"; + locations."/".proxyPass = "http://${config.services.elnafo-radio.host}:${config.services.elnafo-radio.port}"; + locations."/synthwave".proxyPass = "http://${config.containers.radio-synthwave.localAddress}:6660"; + locations."/non-stop-pop".proxyPass = "http://${config.containers.radio-non-stop-pop.localAddress}:6661"; }; }