diff --git a/hosts/hetzner-vm/services/mpd-broadcast/broadcast.nix b/hosts/hetzner-vm/services/mpd-broadcast/broadcast.nix new file mode 100644 index 0000000..a592ccf --- /dev/null +++ b/hosts/hetzner-vm/services/mpd-broadcast/broadcast.nix @@ -0,0 +1,11 @@ +{ tree, ... }: { + imports = with tree; [ + # systemwide pulseaudio w/ recv native localhost + # to broadcast to all speakers over rtp + profiles.sound.pulseaudio.pulse-systemwide + profiles.sound.pulseaudio.pulse-recv-native-localhost + ] ++ [ + ./hosts/lappy.nix + ]; + +} diff --git a/hosts/hetzner-vm/services/mpd-broadcast/hosts/lappy.nix b/hosts/hetzner-vm/services/mpd-broadcast/hosts/lappy.nix new file mode 100644 index 0000000..e5bde1a --- /dev/null +++ b/hosts/hetzner-vm/services/mpd-broadcast/hosts/lappy.nix @@ -0,0 +1,21 @@ +{ ... }: +let + sink_name = "rtp-lappy"; + description = "Laptop Output"; + ip_addr = "100.115.10.34"; +in { + hardware.pulseaudio = { + extraConfig = '' + load-module module-null-sink sink_name=${sink_name} sink_properties="device.description='${description}'" + load-module module-rtp-send source=${sink_name}.monitor destination_ip=${ip_addr} + ''; + }; + services.mpd.extraConfig = '' + audio_output { + type "pulse" + name "${description}" + target "${sink_name}" + server "127.0.0.1" + } + ''; +} diff --git a/hosts/hetzner-vm/services/mpd.nix b/hosts/hetzner-vm/services/mpd.nix index 55737a9..243949f 100644 --- a/hosts/hetzner-vm/services/mpd.nix +++ b/hosts/hetzner-vm/services/mpd.nix @@ -1,19 +1,8 @@ { pkgs, lib, tree, ... }: { - imports = with tree; [ - # systemwide pulseaudio w/ recv native localhost - # to broadcast to all speakers over rtp - profiles.sound.pulseaudio.pulse-systemwide - profiles.sound.pulseaudio.pulse-recv-native-localhost + imports = [ + ./mpd-broadcast/broadcast.nix ]; - hardware.pulseaudio = { - extraConfig = '' - # laptop - load-module module-null-sink sink_name=rtp-lappy sink_properties="device.description='Laptop Output'" - load-module module-rtp-send source=rtp-lappy.monitor destination_ip=100.115.10.34 - ''; - }; - environment.systemPackages = with pkgs; [ mpc_cli ]; services.mpd = { @@ -40,12 +29,6 @@ always_on "yes" tags "yes" } - audio_output { - type "pulse" - name "Lappy Out" - target "rtp-lappy" - server "127.0.0.1" - } ''; };