From c696c800126f1882890eb83d446b1c17708f7dc5 Mon Sep 17 00:00:00 2001 From: ChaotiCryptidz Date: Tue, 25 Jan 2022 14:45:05 +0000 Subject: [PATCH] i give up --- .../services/mpd-broadcast/broadcast.nix | 2 +- .../mpd-broadcast/hosts/raspberry.nix | 21 +++++++++++++++++++ hosts/hetzner-vm/services/mpd.nix | 2 +- hosts/raspberry/raspberry.nix | 6 +++--- hosts/raspberry/services/btattach.nix | 10 --------- hosts/raspberry/services/mpd-recv.nix | 18 ++++++++++++++++ .../pulse-recv-native-localhost.nix | 2 +- profiles/sound/pulseaudio/pulse-recv-rtp.nix | 2 +- 8 files changed, 46 insertions(+), 17 deletions(-) create mode 100644 hosts/hetzner-vm/services/mpd-broadcast/hosts/raspberry.nix delete mode 100644 hosts/raspberry/services/btattach.nix create mode 100644 hosts/raspberry/services/mpd-recv.nix diff --git a/hosts/hetzner-vm/services/mpd-broadcast/broadcast.nix b/hosts/hetzner-vm/services/mpd-broadcast/broadcast.nix index 04c76b1..c21f77a 100644 --- a/hosts/hetzner-vm/services/mpd-broadcast/broadcast.nix +++ b/hosts/hetzner-vm/services/mpd-broadcast/broadcast.nix @@ -5,6 +5,6 @@ # to broadcast to all speakers over rtp profiles.sound.pulseaudio.pulse-systemwide profiles.sound.pulseaudio.pulse-recv-native-localhost - ] ++ [ ./hosts/lappy.nix ]; + ] ++ [ ./hosts/lappy.nix ./hosts/raspberry.nix ]; } diff --git a/hosts/hetzner-vm/services/mpd-broadcast/hosts/raspberry.nix b/hosts/hetzner-vm/services/mpd-broadcast/hosts/raspberry.nix new file mode 100644 index 0000000..72f8e5d --- /dev/null +++ b/hosts/hetzner-vm/services/mpd-broadcast/hosts/raspberry.nix @@ -0,0 +1,21 @@ +{ ... }: +let + sink_name = "rtp-raspberry"; + description = "Raspberry Output"; + ip_addr = "100.118.202.64"; +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 25b495d..b3ff667 100644 --- a/hosts/hetzner-vm/services/mpd.nix +++ b/hosts/hetzner-vm/services/mpd.nix @@ -1,5 +1,5 @@ { pkgs, lib, tree, ... }: { - imports = [ ./mpd-broadcast/broadcast.nix ]; + #imports = [ ./mpd-broadcast/broadcast.nix ]; environment.systemPackages = with pkgs; [ mpc_cli ]; diff --git a/hosts/raspberry/raspberry.nix b/hosts/raspberry/raspberry.nix index c63e3d1..4fa616c 100644 --- a/hosts/raspberry/raspberry.nix +++ b/hosts/raspberry/raspberry.nix @@ -9,8 +9,8 @@ profiles.tailscale profiles.sshd - # make bluetooth work on pi - hosts.raspberry.services.btattach + hosts.raspberry.services.mpd-recv + profiles.connectivity.bluetooth profiles.connectivity.ios @@ -33,7 +33,7 @@ networking.useDHCP = true; networking.wireless = { - enable = false; + enable = true; environmentFile = "/secrets/wifi-env"; networks.BT-JGA898.psk = "@PSK_HOME@"; }; diff --git a/hosts/raspberry/services/btattach.nix b/hosts/raspberry/services/btattach.nix deleted file mode 100644 index 0ef275c..0000000 --- a/hosts/raspberry/services/btattach.nix +++ /dev/null @@ -1,10 +0,0 @@ -{ pkgs, ... }: { - systemd.services.btattach = { - before = [ "bluetooth.service" ]; - after = [ "dev-ttyAMA0.device" ]; - wantedBy = [ "multi-user.target" ]; - serviceConfig = { - ExecStart = "${pkgs.bluez}/bin/btattach -B /dev/ttyS1 -P bcm -S 3000000"; - }; - }; -} diff --git a/hosts/raspberry/services/mpd-recv.nix b/hosts/raspberry/services/mpd-recv.nix new file mode 100644 index 0000000..e53ed0a --- /dev/null +++ b/hosts/raspberry/services/mpd-recv.nix @@ -0,0 +1,18 @@ +{ tree, ... }: { + imports = with tree; [ + profiles.connectivity.bluetooth + + profiles.sound.pulseaudio.pulse + profiles.sound.pulseaudio.pulse-systemwide + profiles.sound.pulseaudio.pulse-bluetooth + profiles.sound.pulseaudio.pulse-recv-native-localhost + profiles.sound.pulseaudio.pulse-recv-rtp + ]; + + hardware.pulseaudio.extraConfig = '' + load-module module-bluetooth-policy + load-module module-bluetooth-discover + set-default-sink bluez_card.3E_39_E7_B2_86_29 + ''; +} +p \ No newline at end of file diff --git a/profiles/sound/pulseaudio/pulse-recv-native-localhost.nix b/profiles/sound/pulseaudio/pulse-recv-native-localhost.nix index 63f20a7..9e82750 100644 --- a/profiles/sound/pulseaudio/pulse-recv-native-localhost.nix +++ b/profiles/sound/pulseaudio/pulse-recv-native-localhost.nix @@ -1,7 +1,7 @@ { ... }: { hardware.pulseaudio = { extraConfig = '' - load-module module-native-protocol-tcp auth-anonymous=1 auth-ip-acl=127.0.0.1; + load-module module-native-protocol-tcp auth-anonymous=1 auth-ip-acl=127.0.0.1;192.168.1.0/24;100.115.10.34 ''; }; } diff --git a/profiles/sound/pulseaudio/pulse-recv-rtp.nix b/profiles/sound/pulseaudio/pulse-recv-rtp.nix index a4adde2..90c62b4 100644 --- a/profiles/sound/pulseaudio/pulse-recv-rtp.nix +++ b/profiles/sound/pulseaudio/pulse-recv-rtp.nix @@ -1,7 +1,7 @@ { ... }: { hardware.pulseaudio = { extraConfig = '' - load-module module-rtp-recv latency_msec=50 sap_address=0.0.0.0 + load-module module-rtp-recv latency_msec=500 sap_address=0.0.0.0 ''; }; }