1 { lib, stdenv, fetchFromGitHub, meson, ninja, pkg-config, glib, systemd, boost, fmt, buildPackages
3 , AudioToolbox, AudioUnit
5 , curl, libcdio, libcdio-paranoia, 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 ];
40 cdio_paranoia = [ libcdio libcdio-paranoia ];
42 io_uring = [ liburing ];
45 smbclient = [ samba ];
50 audiofile = [ audiofile ];
54 fluidsynth = [ fluidsynth ];
55 gme = [ game-music-emu ];
57 mikmod = [ libmikmod ];
60 vorbis = [ libvorbis ];
62 vorbisenc = [ libvorbis ];
65 libsamplerate = [ libsamplerate ];
70 pipewire = [ pipewire ];
71 pulse = [ libpulseaudio ];
74 qobuz = [ curl libgcrypt yajl ];
75 soundcloud = [ curl yajl ];
77 libmpdclient = [ libmpdclient ];
79 id3tag = [ libid3tag ];
87 systemd = [ systemd ];
89 zeroconf = [ avahi dbus ];
92 nativeFeatureDependencies = {
93 documentation = [ doxygen python3Packages.sphinx ];
96 run = { features ? null }:
98 # Disable platform specific features if needed
99 # using libmad to decode mp3 files on darwin is causing a segfault -- there
100 # is probably a solution, but I'm disabling it for now
101 platformMask = lib.optionals stdenv.hostPlatform.isDarwin [ "mad" "pulse" "jack" "smbclient" ]
102 ++ lib.optionals (!stdenv.hostPlatform.isLinux) [ "alsa" "pipewire" "io_uring" "systemd" "syslog" ];
104 knownFeatures = builtins.attrNames featureDependencies ++ builtins.attrNames nativeFeatureDependencies;
105 platformFeatures = lib.subtractLists platformMask knownFeatures;
107 features_ = if (features == null )
108 then platformFeatures
110 let unknown = lib.subtractLists knownFeatures features; in
112 then throw "Unknown feature(s): ${lib.concatStringsSep " " unknown}"
114 let unsupported = lib.subtractLists platformFeatures features; in
115 if (unsupported != [])
116 then throw "Feature(s) ${lib.concatStringsSep " " unsupported} are not supported on ${stdenv.hostPlatform.system}"
119 in stdenv.mkDerivation rec {
123 src = fetchFromGitHub {
124 owner = "MusicPlayerDaemon";
127 sha256 = "sha256-QURq7ysSsxmBOtoBlPTPWiloXQpjEdxnM0L1fLwXfpw=";
134 # According to the configurePhase of meson, gtest is considered a
135 # runtime dependency. Quoting:
137 # Run-time dependency GTest found: YES 1.10.0
140 ++ concatAttrVals features_ featureDependencies
141 ++ lib.optionals stdenv.hostPlatform.isDarwin [ AudioToolbox AudioUnit ];
143 nativeBuildInputs = [
148 ++ concatAttrVals features_ nativeFeatureDependencies;
150 depsBuildBuild = [ buildPackages.stdenv.cc ];
152 postPatch = lib.optionalString (stdenv.hostPlatform.isDarwin && lib.versionOlder stdenv.hostPlatform.darwinSdkVersion "12.0") ''
153 substituteInPlace src/output/plugins/OSXOutputPlugin.cxx \
154 --replace kAudioObjectPropertyElement{Main,Master} \
155 --replace kAudioHardwareServiceDeviceProperty_Virtual{Main,Master}Volume
158 # Otherwise, the meson log says:
160 # Program zip found: NO
161 nativeCheckInputs = [ zip ];
165 mesonAutoFeatures = "disabled";
167 outputs = [ "out" "doc" ]
168 ++ lib.optional (builtins.elem "documentation" features_) "man";
170 CXXFLAGS = lib.optionals stdenv.hostPlatform.isDarwin [
171 "-D__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES=0"
179 ++ map (x: "-D${x}=enabled") features_
180 ++ map (x: "-D${x}=disabled") (lib.subtractLists features_ knownFeatures)
181 ++ lib.optional (builtins.elem "zeroconf" features_)
183 ++ lib.optional (builtins.elem "systemd" features_)
184 "-Dsystemd_system_unit_dir=etc/systemd/system";
186 passthru.tests.nixos = nixosTests.mpd;
189 description = "Flexible, powerful daemon for playing music";
190 homepage = "https://www.musicpd.org/";
191 license = licenses.gpl2Only;
192 maintainers = with maintainers; [ astsmtl tobim ];
193 platforms = platforms.unix;
197 Music Player Daemon (MPD) is a flexible, powerful daemon for playing
198 music. Through plugins and libraries it can play a variety of sound
199 files while being controlled by its network protocol.
206 mpd-small = run { features = [
207 "webdav" "curl" "mms" "bzip2" "zzip" "nfs"
208 "audiofile" "faad" "flac" "gme"
209 "mpg123" "opus" "vorbis" "vorbisenc"
210 "lame" "libsamplerate" "shout"
211 "libmpdclient" "id3tag" "expat" "pcre"
214 ] ++ lib.optionals stdenv.hostPlatform.isLinux [
215 "alsa" "systemd" "syslog" "io_uring"
216 ] ++ lib.optionals (!stdenv.hostPlatform.isDarwin) [
219 mpdWithFeatures = run;