Skip to content

Commit

Permalink
mpd: 0.20.13 -> 0.21.16 (NixOS#57608)
Browse files Browse the repository at this point in the history
* Refactor mpd

* mpd: 0.20.13 -> 0.21.5

Switch to meson based build, following upstream.

* Fix mpd on darwin

* mpd: 0.21.5 -> 0.21.6

* mpd-small: init add 0.21.6

* Update to 0.21.8 & fix ouput path

Also use pname instead of name.

* Update to 0.21.9

* Integrate review suggestions

- Expose run function as mpdWithFeatures.
- Throw on invalid feature requests.
- Drop major/minor version variables.
- Cosmetic improvements.

* Update to 0.21.10

* mpd: 0.21.10 -> 0.21.11

* mpd: 0.21.11 -> 0.21.12

* mpd: log to journal

* mpd: 0.21.12 -> 0.21.14

* mpd: add tobim to maintainers

* mpd: reenable syslog support

* mpd: 0.21.14 -> 0.21.15

* mpd: 0.21.15 -> 0.21.16
  • Loading branch information
tobim authored and fpletz committed Nov 13, 2019
1 parent a95e0ac commit 4a9d549
Show file tree
Hide file tree
Showing 3 changed files with 150 additions and 136 deletions.
1 change: 0 additions & 1 deletion nixos/modules/services/audio/mpd.nix
Expand Up @@ -18,7 +18,6 @@ let
''}
state_file "${cfg.dataDir}/state"
sticker_file "${cfg.dataDir}/sticker.sql"
log_file "syslog"
user "${cfg.user}"
group "${cfg.group}"
Expand Down
282 changes: 148 additions & 134 deletions pkgs/servers/mpd/default.nix
@@ -1,148 +1,162 @@
{ stdenv, fetchFromGitHub, autoreconfHook, pkgconfig, glib, systemd, boost, darwin
, alsaSupport ? true, alsaLib
, avahiSupport ? true, avahi, dbus
, flacSupport ? true, flac
, vorbisSupport ? true, libvorbis
, madSupport ? true, libmad
, id3tagSupport ? true, libid3tag
, mikmodSupport ? true, libmikmod
, shoutSupport ? true, libshout
, sqliteSupport ? true, sqlite
, curlSupport ? true, curl
, audiofileSupport ? true, audiofile
, bzip2Support ? true, bzip2
, ffmpegSupport ? true, ffmpeg
, fluidsynthSupport ? true, fluidsynth
, zipSupport ? true, zziplib
, samplerateSupport ? true, libsamplerate
, mmsSupport ? true, libmms
, mpg123Support ? true, mpg123
, aacSupport ? true, faad2
, lameSupport ? true, lame
, pulseaudioSupport ? true, libpulseaudio
, jackSupport ? true, libjack2
, gmeSupport ? true, game-music-emu
, icuSupport ? true, icu
, clientSupport ? true, mpd_clientlib
, opusSupport ? true, libopus
, soundcloudSupport ? true, yajl
, nfsSupport ? true, libnfs
, smbSupport ? true, samba
{ stdenv, fetchFromGitHub, meson, ninja, pkgconfig, glib, systemd, boost, darwin
# Inputs
, curl, libmms, libnfs, samba
# Archive support
, bzip2, zziplib
# Codecs
, audiofile, faad2, ffmpeg, flac, fluidsynth, game-music-emu
, libmad, libmikmod, mpg123, libopus, libvorbis, lame
# Filters
, libsamplerate
# Outputs
, alsaLib, libjack2, libpulseaudio, libshout
# Misc
, icu, sqlite, avahi, dbus, pcre, libgcrypt, expat
# Services
, yajl
# Client support
, mpd_clientlib
# Tag support
, libid3tag
}:

assert avahiSupport -> avahi != null && dbus != null;

let
opt = stdenv.lib.optional;
mkFlag = c: f: if c then "--enable-${f}" else "--disable-${f}";
major = "0.20";
minor = "23";

in stdenv.mkDerivation rec {
pname = "mpd";
version = "${major}${if minor == "" then "" else "." + minor}";
lib = stdenv.lib;

src = fetchFromGitHub {
owner = "MusicPlayerDaemon";
repo = "MPD";
rev = "v${version}";
sha256 = "1z1pdgiddimnmck0ardrpxkvgk1wn9zxri5wfv5ppasbb7kfm350";
featureDependencies = {
# Storage plugins
udisks = [ dbus ];
webdav = [ curl expat ];
# Input plugins
curl = [ curl ];
mms = [ libmms ];
nfs = [ libnfs ];
smbclient = [ samba ];
# Archive support
bzip2 = [ bzip2 ];
zzip = [ zziplib ];
# Decoder plugins
audiofile = [ audiofile ];
faad = [ faad2 ];
ffmpeg = [ ffmpeg ];
flac = [ flac ];
fluidsynth = [ fluidsynth ];
gme = [ game-music-emu ];
mad = [ libmad ];
mikmod = [ libmikmod ];
mpg123 = [ mpg123 ];
opus = [ libopus ];
vorbis = [ libvorbis ];
# Encoder plugins
vorbisenc = [ libvorbis ];
lame = [ lame ];
# Filter plugins
libsamplerate = [ libsamplerate ];
# Output plugins
alsa = [ alsaLib ];
jack = [ libjack2 ];
pulse = [ libpulseaudio ];
shout = [ libshout ];
# Commercial services
qobuz = [ curl libgcrypt yajl ];
soundcloud = [ curl yajl ];
tidal = [ curl yajl ];
# Client support
libmpdclient = [ mpd_clientlib ];
# Tag support
id3tag = [ libid3tag ];
# Misc
dbus = [ dbus ];
expat = [ expat ];
icu = [ icu ];
pcre = [ pcre ];
sqlite = [ sqlite ];
syslog = [ ];
systemd = [ systemd ];
yajl = [ yajl ];
zeroconf = [ avahi dbus ];
};

patches = [ ./x86.patch ];
run = { features ? null }:
let
# Disable platform specific features if needed
# using libmad to decode mp3 files on darwin is causing a segfault -- there
# is probably a solution, but I'm disabling it for now
platformMask = lib.optionals stdenv.isDarwin [ "mad" "pulse" "jack" "nfs" "smb" ]
++ lib.optionals (!stdenv.isLinux) [ "alsa" "systemd" "syslog" ];

buildInputs = [ glib boost ]
++ opt stdenv.isDarwin darwin.apple_sdk.frameworks.CoreAudioKit
++ opt stdenv.isLinux systemd
++ opt (stdenv.isLinux && alsaSupport) alsaLib
++ opt avahiSupport avahi
++ opt avahiSupport dbus
++ opt flacSupport flac
++ opt vorbisSupport libvorbis
# using libmad to decode mp3 files on darwin is causing a segfault -- there
# is probably a solution, but I'm disabling it for now
++ opt (!stdenv.isDarwin && madSupport) libmad
++ opt id3tagSupport libid3tag
++ opt mikmodSupport libmikmod
++ opt shoutSupport libshout
++ opt sqliteSupport sqlite
++ opt curlSupport curl
++ opt bzip2Support bzip2
++ opt audiofileSupport audiofile
++ opt ffmpegSupport ffmpeg
++ opt fluidsynthSupport fluidsynth
++ opt samplerateSupport libsamplerate
++ opt mmsSupport libmms
++ opt mpg123Support mpg123
++ opt aacSupport faad2
++ opt lameSupport lame
++ opt zipSupport zziplib
++ opt (!stdenv.isDarwin && pulseaudioSupport) libpulseaudio
++ opt (!stdenv.isDarwin && jackSupport) libjack2
++ opt gmeSupport game-music-emu
++ opt icuSupport icu
++ opt clientSupport mpd_clientlib
++ opt opusSupport libopus
++ opt soundcloudSupport yajl
++ opt (!stdenv.isDarwin && nfsSupport) libnfs
++ opt (!stdenv.isDarwin && smbSupport) samba;
knownFeatures = builtins.attrNames featureDependencies;
platformFeatures = lib.subtractLists platformMask knownFeatures;

nativeBuildInputs = [ autoreconfHook pkgconfig ];
features_ = if (features == null )
then platformFeatures
else
let unknown = lib.subtractLists knownFeatures features; in
if (unknown != [])
then throw "Unknown feature(s): ${lib.concatStringsSep " " unknown}"
else
let unsupported = lib.subtractLists platformFeatures features; in
if (unsupported != [])
then throw "Feature(s) ${lib.concatStringsSep " " unsupported} are not supported on ${stdenv.hostPlatform.system}"
else features;

enableParallelBuilding = true;
in stdenv.mkDerivation rec {
pname = "mpd";
version = "0.21.16";

configureFlags =
[ (mkFlag (!stdenv.isDarwin && alsaSupport) "alsa")
(mkFlag flacSupport "flac")
(mkFlag vorbisSupport "vorbis")
(mkFlag vorbisSupport "vorbis-encoder")
(mkFlag (!stdenv.isDarwin && madSupport) "mad")
(mkFlag mikmodSupport "mikmod")
(mkFlag id3tagSupport "id3")
(mkFlag shoutSupport "shout")
(mkFlag sqliteSupport "sqlite")
(mkFlag curlSupport "curl")
(mkFlag audiofileSupport "audiofile")
(mkFlag bzip2Support "bzip2")
(mkFlag ffmpegSupport "ffmpeg")
(mkFlag fluidsynthSupport "fluidsynth")
(mkFlag zipSupport "zzip")
(mkFlag samplerateSupport "lsr")
(mkFlag mmsSupport "mms")
(mkFlag mpg123Support "mpg123")
(mkFlag aacSupport "aac")
(mkFlag lameSupport "lame-encoder")
(mkFlag (!stdenv.isDarwin && pulseaudioSupport) "pulse")
(mkFlag (!stdenv.isDarwin && jackSupport) "jack")
(mkFlag stdenv.isDarwin "osx")
(mkFlag icuSupport "icu")
(mkFlag gmeSupport "gme")
(mkFlag clientSupport "libmpdclient")
(mkFlag opusSupport "opus")
(mkFlag soundcloudSupport "soundcloud")
(mkFlag (!stdenv.isDarwin && nfsSupport) "libnfs")
(mkFlag (!stdenv.isDarwin && smbSupport) "smbclient")
"--enable-debug"
"--with-zeroconf=avahi"
]
++ opt stdenv.isLinux
"--with-systemdsystemunitdir=$(out)/etc/systemd/system";
src = fetchFromGitHub {
owner = "MusicPlayerDaemon";
repo = "MPD";
rev = "v${version}";
sha256 = "0yfzn1hcyww8z5pp70n7iinycz097vjc6q9fzmfrc6ikvz3db8f4";
};

NIX_LDFLAGS = ''
${if shoutSupport then "-lshout" else ""}
'';
buildInputs = [ glib boost ]
++ (lib.concatLists (lib.attrVals features_ featureDependencies))
++ lib.optional stdenv.isDarwin darwin.apple_sdk.frameworks.AudioToolbox;

meta = with stdenv.lib; {
description = "A flexible, powerful daemon for playing music";
homepage = http://mpd.wikia.com/wiki/Music_Player_Daemon_Wiki;
license = licenses.gpl2;
maintainers = with maintainers; [ astsmtl fuuzetsu ehmry fpletz ];
platforms = platforms.unix;
nativeBuildInputs = [ meson ninja pkgconfig ];

longDescription = ''
Music Player Daemon (MPD) is a flexible, powerful daemon for playing
music. Through plugins and libraries it can play a variety of sound
files while being controlled by its network protocol.
'';
};
enableParallelBuilding = true;

mesonAutoFeatures = "disabled";
mesonFlags =
map (x: "-D${x}=enabled") features_
++ map (x: "-D${x}=disabled") (lib.subtractLists features_ knownFeatures)
++ lib.optional (builtins.elem "zeroconf" features_)
"-Dzeroconf=avahi"
++ lib.optional (builtins.elem "systemd" features_)
"-Dsystemd_system_unit_dir=etc/systemd/system";

meta = with stdenv.lib; {
description = "A flexible, powerful daemon for playing music";
homepage = http://mpd.wikia.com/wiki/Music_Player_Daemon_Wiki;
license = licenses.gpl2;
maintainers = with maintainers; [ astsmtl fuuzetsu ehmry fpletz tobim ];
platforms = platforms.unix;

longDescription = ''
Music Player Daemon (MPD) is a flexible, powerful daemon for playing
music. Through plugins and libraries it can play a variety of sound
files while being controlled by its network protocol.
'';
};
};
in
{
mpd = run { };
mpd-small = run { features = [
"webdav" "curl" "mms" "bzip2" "zzip"
"audiofile" "faad" "flac" "gme" "mad"
"mpg123" "opus" "vorbis" "vorbisenc"
"lame" "libsamplerate" "shout"
"libmpdclient" "id3tag" "expat" "pcre"
"yajl" "sqlite"
"soundcloud" "qobuz" "tidal"
] ++ lib.optionals stdenv.isLinux [
"alsa" "systemd" "syslog"
] ++ lib.optionals (!stdenv.isDarwin) [
"mad" "jack" "nfs"
]; };
mpdWithFeatures = run;
}
3 changes: 2 additions & 1 deletion pkgs/top-level/all-packages.nix
Expand Up @@ -15127,7 +15127,8 @@ in
mod_python = pkgs.apacheHttpdPackages.mod_python;
mod_wsgi = pkgs.apacheHttpdPackages.mod_wsgi;

mpd = callPackage ../servers/mpd (config.mpd or {});
inherit (callPackages ../servers/mpd { })
mpd mpd-small mpdWithFeatures;

mpd_clientlib = callPackage ../servers/mpd/clientlib.nix { };

Expand Down

0 comments on commit 4a9d549

Please sign in to comment.