1 { lib, stdenv, fetchFromGitHub, meson, ninja, pkg-config, glib, systemd, boost, fmt, buildPackages
3 , AudioToolbox, AudioUnit
5 , curl, libmms, libnfs, liburing, samba
9 , audiofile, faad2, ffmpeg, flac, fluidsynth, game-music-emu
10 , libmad, libmikmod, mpg123, libopus, libvorbis, lame
14 , alsa-lib, libjack2, libpulseaudio, libshout, pipewire
16 , icu, sqlite, avahi, dbus, pcre2, libgcrypt, expat
26 , python3Packages # for sphinx-build
33 concatAttrVals = nameList: set: lib.concatMap (x: set.${x} or []) nameList;
35 featureDependencies = {
38 webdav = [ curl expat ];
41 io_uring = [ liburing ];
44 smbclient = [ samba ];
49 audiofile = [ audiofile ];
53 fluidsynth = [ fluidsynth ];
54 gme = [ game-music-emu ];
56 mikmod = [ libmikmod ];
59 vorbis = [ libvorbis ];
61 vorbisenc = [ libvorbis ];
64 libsamplerate = [ libsamplerate ];
69 pipewire = [ pipewire ];
70 pulse = [ libpulseaudio ];
73 qobuz = [ curl libgcrypt yajl ];
74 soundcloud = [ curl yajl ];
76 libmpdclient = [ libmpdclient ];
78 id3tag = [ libid3tag ];
86 systemd = [ systemd ];
88 zeroconf = [ avahi dbus ];
91 nativeFeatureDependencies = {
92 documentation = [ doxygen python3Packages.sphinx ];
95 run = { features ? null }:
97 # Disable platform specific features if needed
98 # using libmad to decode mp3 files on darwin is causing a segfault -- there
99 # is probably a solution, but I'm disabling it for now
100 platformMask = lib.optionals stdenv.isDarwin [ "mad" "pulse" "jack" "smbclient" ]
101 ++ lib.optionals (!stdenv.isLinux) [ "alsa" "pipewire" "io_uring" "systemd" "syslog" ];
103 knownFeatures = builtins.attrNames featureDependencies ++ builtins.attrNames nativeFeatureDependencies;
104 platformFeatures = lib.subtractLists platformMask knownFeatures;
106 features_ = if (features == null )
107 then platformFeatures
109 let unknown = lib.subtractLists knownFeatures features; in
111 then throw "Unknown feature(s): ${lib.concatStringsSep " " unknown}"
113 let unsupported = lib.subtractLists platformFeatures features; in
114 if (unsupported != [])
115 then throw "Feature(s) ${lib.concatStringsSep " " unsupported} are not supported on ${stdenv.hostPlatform.system}"
118 in stdenv.mkDerivation rec {
122 src = fetchFromGitHub {
123 owner = "MusicPlayerDaemon";
126 sha256 = "sha256-QURq7ysSsxmBOtoBlPTPWiloXQpjEdxnM0L1fLwXfpw=";
133 # According to the configurePhase of meson, gtest is considered a
134 # runtime dependency. Quoting:
136 # Run-time dependency GTest found: YES 1.10.0
139 ++ concatAttrVals features_ featureDependencies
140 ++ lib.optionals stdenv.isDarwin [ AudioToolbox AudioUnit ];
142 nativeBuildInputs = [
147 ++ concatAttrVals features_ nativeFeatureDependencies;
149 depsBuildBuild = [ buildPackages.stdenv.cc ];
151 postPatch = lib.optionalString (stdenv.isDarwin && lib.versionOlder stdenv.hostPlatform.darwinSdkVersion "12.0") ''
152 substituteInPlace src/output/plugins/OSXOutputPlugin.cxx \
153 --replace kAudioObjectPropertyElement{Main,Master} \
154 --replace kAudioHardwareServiceDeviceProperty_Virtual{Main,Master}Volume
157 # Otherwise, the meson log says:
159 # Program zip found: NO
160 nativeCheckInputs = [ zip ];
164 mesonAutoFeatures = "disabled";
166 outputs = [ "out" "doc" ]
167 ++ lib.optional (builtins.elem "documentation" features_) "man";
169 CXXFLAGS = lib.optionals stdenv.isDarwin [
170 "-D__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES=0"
178 ++ map (x: "-D${x}=enabled") features_
179 ++ map (x: "-D${x}=disabled") (lib.subtractLists features_ knownFeatures)
180 ++ lib.optional (builtins.elem "zeroconf" features_)
182 ++ lib.optional (builtins.elem "systemd" features_)
183 "-Dsystemd_system_unit_dir=etc/systemd/system";
185 passthru.tests.nixos = nixosTests.mpd;
188 description = "Flexible, powerful daemon for playing music";
189 homepage = "https://www.musicpd.org/";
190 license = licenses.gpl2Only;
191 maintainers = with maintainers; [ astsmtl tobim ];
192 platforms = platforms.unix;
196 Music Player Daemon (MPD) is a flexible, powerful daemon for playing
197 music. Through plugins and libraries it can play a variety of sound
198 files while being controlled by its network protocol.
205 mpd-small = run { features = [
206 "webdav" "curl" "mms" "bzip2" "zzip" "nfs"
207 "audiofile" "faad" "flac" "gme"
208 "mpg123" "opus" "vorbis" "vorbisenc"
209 "lame" "libsamplerate" "shout"
210 "libmpdclient" "id3tag" "expat" "pcre"
213 ] ++ lib.optionals stdenv.isLinux [
214 "alsa" "systemd" "syslog" "io_uring"
215 ] ++ lib.optionals (!stdenv.isDarwin) [
218 mpdWithFeatures = run;