From 70f47e2f755fcdddae86437cf56153cd6188d4d5 Mon Sep 17 00:00:00 2001 From: L-Nafaryus Date: Sun, 22 Sep 2024 19:47:46 +0500 Subject: [PATCH] catarina: split radio services to containers + new radio station --- .../catarina/services/radio.nix | 136 +++++++++++++----- 1 file changed, 98 insertions(+), 38 deletions(-) diff --git a/nixosConfigurations/catarina/services/radio.nix b/nixosConfigurations/catarina/services/radio.nix index 52fd00a..84b0f39 100644 --- a/nixosConfigurations/catarina/services/radio.nix +++ b/nixosConfigurations/catarina/services/radio.nix @@ -1,43 +1,104 @@ {config, ...}: { - containers.radio-synthwave = { - autoStart = true; - privateNetwork = true; + containers = { + radio-synthwave = { + autoStart = true; + privateNetwork = true; + hostAddress = "10.231.136.1"; + localAddress = "10.231.136.2"; - config = { - config, - pkgs, - lib, - ... - }: { - services.mpd = { - enable = true; - musicDirectory = "/home/l-nafaryus/Music"; - network.listenAddress = "any"; - #network.startWhenNeeded = true; - user = "l-nafaryus"; - network.port = 6600; - extraConfig = '' - audio_output { - type "httpd" - name "Radio" - port "6660" - bind_to_address "127.0.0.1" - encoder "lame" - max_clients "0" - website "https://radio.elnafo.ru/synthwave" - always_on "yes" - tags "yes" - bitrate "128" - format "44100:16:1" - } - ''; + bindMounts = { + "/var/lib/music" = { + hostPath = "/home/l-nafaryus/Music"; + isReadOnly = true; + }; }; - system.stateVersion = "24.05"; + config = { + config, + pkgs, + lib, + ... + }: { + services.mpd = { + enable = true; + musicDirectory = "/var/lib/music"; + network.listenAddress = "any"; + #network.startWhenNeeded = true; + user = "mpd"; + network.port = 6600; + extraConfig = '' + audio_output { + type "httpd" + name "Radio" + port "6660" + encoder "lame" + max_clients "0" + website "https://radio.elnafo.ru/synthwave" + always_on "yes" + tags "yes" + bitrate "128" + format "44100:16:1" + } + ''; + }; - networking.firewall = { - enable = true; - allowedTCPPorts = [6600 6660]; + system.stateVersion = "24.05"; + + networking.firewall = { + enable = true; + allowedTCPPorts = [6600 6660]; + }; + }; + }; + + radio-non-stop = { + autoStart = true; + privateNetwork = true; + hostAddress = "10.231.136.1"; + localAddress = "10.231.136.3"; + + bindMounts = { + "/var/lib/music" = { + hostPath = "/home/l-nafaryus/Music"; + isReadOnly = true; + }; + }; + + config = { + config, + pkgs, + lib, + ... + }: { + services.mpd = { + enable = true; + musicDirectory = "/var/lib/music"; + network.listenAddress = "any"; + #network.startWhenNeeded = true; + user = "mpd"; + network.port = 6601; + extraConfig = '' + audio_output { + type "httpd" + name "Radio" + port "6661" + encoder "lame" + max_clients "0" + website "https://radio.elnafo.ru/non-stop" + always_on "yes" + tags "yes" + bitrate "128" + format "44100:16:1" + } + ''; + }; + + system.stateVersion = "24.05"; + + networking.firewall = { + enable = true; + allowedTCPPorts = [6601 6661]; + }; }; }; }; @@ -45,8 +106,7 @@ services.nginx.virtualHosts."radio.elnafo.ru" = { forceSSL = true; useACMEHost = "elnafo.ru"; - locations."/synthwave".proxyPass = "http://127.0.0.1:6660"; + locations."/synthwave".proxyPass = "http://10.231.136.2:6660"; + locations."/non-stop".proxyPass = "http://10.231.136.3:6661"; }; - - networking.firewall.allowedTCPPorts = [6600]; }