From c7f5ce4a368960f955832ea49ce6e83fe5c12eee Mon Sep 17 00:00:00 2001 From: Christoph Urlacher Date: Tue, 8 Jul 2025 23:08:40 +0200 Subject: [PATCH] Modules: Add mpd module --- home/modules/mpd/default.nix | 71 ++++++++++++++++++++++++++++++++++++ home/modules/mpd/options.nix | 7 ++++ 2 files changed, 78 insertions(+) create mode 100644 home/modules/mpd/default.nix create mode 100644 home/modules/mpd/options.nix diff --git a/home/modules/mpd/default.nix b/home/modules/mpd/default.nix new file mode 100644 index 00000000..4c1b1ca7 --- /dev/null +++ b/home/modules/mpd/default.nix @@ -0,0 +1,71 @@ +{ + config, + nixosConfig, + lib, + mylib, + pkgs, + ... +}: let + inherit (config.modules) mpd; +in { + options.modules.mpd = import ./options.nix {inherit lib mylib;}; + + config = lib.mkIf mpd.enable { + services.mpd = { + enable = true; + dataDir = "${config.home.homeDirectory}/Music/.mpd"; + musicDirectory = "${config.home.homeDirectory}/Music"; + network = { + listenAddress = "127.0.0.1"; # Listen on all addresses: "any" + port = 6600; + }; + extraArgs = ["--verbose"]; + + extraConfig = '' + # Refresh the database whenever files in the musicDirectory change + auto_update "yes" + + # Don't start playback after startup + restore_paused "yes" + + # Use track tags on shuffle and album tags on album play (auto) + # Use album's tags (album) + # Use track's tags (track) + # replaygain "auto" + + # PipeWire main output + audio_output { + type "pipewire" + name "PipeWire Sound Server" + + # Use hardware mixer instead of software volume filter (replaygain_handler "software") + # mixer_type "hardware" + # replay_gain_handler "mixer" + } + + # FiFo output for cava visualization + audio_output { + type "fifo" + name "my_fifo" + path "/tmp/mpd.fifo" + format "44100:16:2" + } + + # Pre-cache 1GB of the queue + # input_cache { + # size "1 GB" + # } + + # follow_outside_symlinks "no" # If mpd should follow symlinks pointing outside the musicDirectory + # follow_inside_symlinks "yes" # If mpd should follow symlinks pointing inside the musicDirectory + ''; + }; + }; + + # MPD integration with mpris (used by player-ctl). + # We want to use mpris as it also supports other players (e.g. Spotify) or browsers. + services.mpd-mpris = { + enable = true; + mpd.useLocal = true; + }; +} diff --git a/home/modules/mpd/options.nix b/home/modules/mpd/options.nix new file mode 100644 index 00000000..2b29e418 --- /dev/null +++ b/home/modules/mpd/options.nix @@ -0,0 +1,7 @@ +{ + lib, + mylib, + ... +}: { + enable = lib.mkEnableOption "Enable the Music Player Daemon"; +}