From 14bbdea9dcb6b708c9dbe0b8d81a62d5814a4d9f Mon Sep 17 00:00:00 2001 From: June Date: Tue, 23 Apr 2024 19:12:16 +0200 Subject: [PATCH] Add MPD to audio service module --- config/hosts/audio-hauptraum-kueche/audio.nix | 1 + config/hosts/audio-hauptraum-tafel/audio.nix | 1 + modules/services/audio/default.nix | 1 + modules/services/audio/mpd.nix | 33 +++++++++++++++++++ 4 files changed, 36 insertions(+) create mode 100644 modules/services/audio/mpd.nix diff --git a/config/hosts/audio-hauptraum-kueche/audio.nix b/config/hosts/audio-hauptraum-kueche/audio.nix index aa49f2f..2a75d8a 100644 --- a/config/hosts/audio-hauptraum-kueche/audio.nix +++ b/config/hosts/audio-hauptraum-kueche/audio.nix @@ -8,6 +8,7 @@ enable = true; name = "Audio Hauptraum Küche"; }; + services.mpd.musicDirectory = "smb://beamer:beamer@beamer.z9.ccchh.net/music"; users.users.chaos.extraGroups = [ "pipewire" ]; } diff --git a/config/hosts/audio-hauptraum-tafel/audio.nix b/config/hosts/audio-hauptraum-tafel/audio.nix index 3389720..f090fd9 100644 --- a/config/hosts/audio-hauptraum-tafel/audio.nix +++ b/config/hosts/audio-hauptraum-tafel/audio.nix @@ -8,6 +8,7 @@ enable = true; name = "Audio Hauptraum Tafel"; }; + services.mpd.musicDirectory = "smb://beamer:beamer@beamer.z9.ccchh.net/music"; users.users.chaos.extraGroups = [ "pipewire" ]; } diff --git a/modules/services/audio/default.nix b/modules/services/audio/default.nix index 6e8a43b..ccd7527 100644 --- a/modules/services/audio/default.nix +++ b/modules/services/audio/default.nix @@ -11,6 +11,7 @@ in { imports = [ ./librespot.nix + ./mpd.nix ./networking.nix ./pipewire.nix ./shairport-sync.nix diff --git a/modules/services/audio/mpd.nix b/modules/services/audio/mpd.nix new file mode 100644 index 0000000..30ce12e --- /dev/null +++ b/modules/services/audio/mpd.nix @@ -0,0 +1,33 @@ +# Links & Resources: +# - https://mpd.readthedocs.io/en/stable/user.html + +{ config, pkgs, lib, ... }: + +with lib; + +let + + cfg = config.ccchh.services.audio; + +in + +{ + config = mkIf cfg.enable { + services.mpd = { + enable = true; + network.listenAddress = "any"; + extraConfig = '' + audio_output { + type "pipewire" + name "Pipewire" + } + ''; + }; + + users.users.mpd.extraGroups = [ "pipewire" ]; + + networking.firewall = { + allowedTCPPorts = [ 6600 ]; + }; + }; +}