1 { stdenv, fetchFromGitHub, meson, ninja, pkgconfig, glib, systemd, boost, darwin
3 , curl, libmms, libnfs, samba
7 , audiofile, faad2, ffmpeg, flac, fluidsynth, game-music-emu
8 , libmad, libmikmod, mpg123, libopus, libvorbis, lame
12 , alsaLib, libjack2, libpulseaudio, libshout
14 , icu, sqlite, avahi, dbus, pcre, libgcrypt, expat
26 featureDependencies = {
29 webdav = [ curl expat ];
34 smbclient = [ samba ];
39 audiofile = [ audiofile ];
43 fluidsynth = [ fluidsynth ];
44 gme = [ game-music-emu ];
46 mikmod = [ libmikmod ];
49 vorbis = [ libvorbis ];
51 vorbisenc = [ libvorbis ];
54 libsamplerate = [ libsamplerate ];
58 pulse = [ libpulseaudio ];
61 qobuz = [ curl libgcrypt yajl ];
62 soundcloud = [ curl yajl ];
63 tidal = [ curl yajl ];
65 libmpdclient = [ mpd_clientlib ];
67 id3tag = [ libid3tag ];
75 systemd = [ systemd ];
77 zeroconf = [ avahi dbus ];
80 run = { features ? null }:
82 # Disable platform specific features if needed
83 # using libmad to decode mp3 files on darwin is causing a segfault -- there
84 # is probably a solution, but I'm disabling it for now
85 platformMask = lib.optionals stdenv.isDarwin [ "mad" "pulse" "jack" "nfs" "smbclient" ]
86 ++ lib.optionals (!stdenv.isLinux) [ "alsa" "systemd" "syslog" ];
88 knownFeatures = builtins.attrNames featureDependencies;
89 platformFeatures = lib.subtractLists platformMask knownFeatures;
91 features_ = if (features == null )
94 let unknown = lib.subtractLists knownFeatures features; in
96 then throw "Unknown feature(s): ${lib.concatStringsSep " " unknown}"
98 let unsupported = lib.subtractLists platformFeatures features; in
99 if (unsupported != [])
100 then throw "Feature(s) ${lib.concatStringsSep " " unsupported} are not supported on ${stdenv.hostPlatform.system}"
103 in stdenv.mkDerivation rec {
107 src = fetchFromGitHub {
108 owner = "MusicPlayerDaemon";
111 sha256 = "0ysyjlmmfm1y5jqyv83bs9p7zqr9pgj1hmdq2b7kx9kridclbnng";
114 buildInputs = [ glib boost ]
115 ++ (lib.concatLists (lib.attrVals features_ featureDependencies))
116 ++ lib.optionals stdenv.isDarwin [ darwin.apple_sdk.frameworks.AudioToolbox darwin.apple_sdk.frameworks.AudioUnit ];
118 nativeBuildInputs = [ meson ninja pkgconfig ];
120 enableParallelBuilding = true;
122 mesonAutoFeatures = "disabled";
124 map (x: "-D${x}=enabled") features_
125 ++ map (x: "-D${x}=disabled") (lib.subtractLists features_ knownFeatures)
126 ++ lib.optional (builtins.elem "zeroconf" features_)
128 ++ lib.optional (builtins.elem "systemd" features_)
129 "-Dsystemd_system_unit_dir=etc/systemd/system";
131 meta = with stdenv.lib; {
132 description = "A flexible, powerful daemon for playing music";
133 homepage = "https://www.musicpd.org/";
134 license = licenses.gpl2;
135 maintainers = with maintainers; [ astsmtl ehmry fpletz tobim ];
136 platforms = platforms.unix;
139 Music Player Daemon (MPD) is a flexible, powerful daemon for playing
140 music. Through plugins and libraries it can play a variety of sound
141 files while being controlled by its network protocol.
148 mpd-small = run { features = [
149 "webdav" "curl" "mms" "bzip2" "zzip"
150 "audiofile" "faad" "flac" "gme" "mad"
151 "mpg123" "opus" "vorbis" "vorbisenc"
152 "lame" "libsamplerate" "shout"
153 "libmpdclient" "id3tag" "expat" "pcre"
155 "soundcloud" "qobuz" "tidal"
156 ] ++ lib.optionals stdenv.isLinux [
157 "alsa" "systemd" "syslog"
158 ] ++ lib.optionals (!stdenv.isDarwin) [
161 mpdWithFeatures = run;