MPD: Difference between revisions
Add description for MPD |
→NixOS installation: correction: startWhenNeeded is no longer under the network attribute. |
||
| (One intermediate revision by one other user not shown) | |||
| Line 1: | Line 1: | ||
[https://www.musicpd.org/ Music Player Daemon] (MPD) is a flexible, powerful, server-side application for playing music. Through plugins and libraries, it can play a variety of sound files while being controlled by its network protocol. | [https://www.musicpd.org/ Music Player Daemon] (MPD) is a flexible, powerful, server-side application for playing music. Through plugins and libraries, it can play a variety of sound files while being controlled by its network protocol. | ||
== Installation == | == Home-manager Installation == | ||
A typical config, running MPD system-wide, will look like this: | Home-manager has a module for MPD which runs it as a systemd user service, giving it easier access to your user's sound server. In most cases no specific audio output configuration is necessary: | ||
<syntaxhighlight lang="nix">services.mpd = { | |||
enable = true; | |||
musicDirectory = "/path/to/music"; | |||
# Optional: | |||
network.listenAddress = "any"; # if you want to allow non-localhost connections | |||
network.startWhenNeeded = true; # systemd feature: only start MPD service upon connection to its socket | |||
};</syntaxhighlight> | |||
== NixOS Installation == | |||
A typical NixOS config, running MPD system-wide, will look like this: | |||
<syntaxhighlight lang="nix"> | <syntaxhighlight lang="nix"> | ||
services.mpd = { | services.mpd = { | ||
| Line 14: | Line 25: | ||
# Optional: | # Optional: | ||
network.listenAddress = "any"; # if you want to allow non-localhost connections | network.listenAddress = "any"; # if you want to allow non-localhost connections | ||
startWhenNeeded = true; # systemd feature: only start MPD service upon connection to its socket | |||
}; | }; | ||
</syntaxhighlight> | </syntaxhighlight> | ||
| Line 20: | Line 31: | ||
== PulseAudio == | == PulseAudio == | ||
In order to use MPD with PulseAudio, enable sound support in the NixOS <code>configuration.nix</code> : | In order to use system-wide MPD with PulseAudio, enable sound support in the NixOS <code>configuration.nix</code> : | ||
<syntaxhighlight lang="nix"> | <syntaxhighlight lang="nix"> | ||
# Enable sound. | # Enable sound. | ||
| Line 96: | Line 107: | ||
Make sure PipeWire is enabled. See [[PipeWire]] | Make sure PipeWire is enabled. See [[PipeWire]] | ||
To use PipeWire, create an <code>audio_output</code> for it: | To use PipeWire with a system-wide MPD instance, create an <code>audio_output</code> for it: | ||
<syntaxhighlight lang="nix"> | <syntaxhighlight lang="nix"> | ||
services.mpd.extraConfig = '' | services.mpd.extraConfig = '' | ||
| Line 109: | Line 120: | ||
=== PipeWire workaround === | === PipeWire workaround === | ||
PipeWire typically runs as a normal user, while MPD will run under a system user. A workaround is to configure MPD to run under the same user as PipeWire: | PipeWire typically runs as a normal user, while a system-wide MPD instance will run under a system user. A workaround is to configure MPD to run under the same user as PipeWire: | ||
<syntaxhighlight lang="nix"> | <syntaxhighlight lang="nix"> | ||