2022-09-30 11:47:45 +00:00
|
|
|
{ lib, stdenv, fetchFromGitHub, meson, ninja, pkg-config, glib, systemd, boost, fmt, buildPackages
|
2021-06-28 23:13:55 +00:00
|
|
|
# Darwin inputs
|
|
|
|
, AudioToolbox, AudioUnit
|
2020-04-24 23:36:52 +00:00
|
|
|
# Inputs
|
2020-10-07 09:15:18 +00:00
|
|
|
, curl, libmms, libnfs, liburing, samba
|
2020-04-24 23:36:52 +00:00
|
|
|
# Archive support
|
|
|
|
, bzip2, zziplib
|
|
|
|
# Codecs
|
2020-07-18 16:06:22 +00:00
|
|
|
, audiofile, faad2, ffmpeg, flac, fluidsynth, game-music-emu
|
2020-04-24 23:36:52 +00:00
|
|
|
, libmad, libmikmod, mpg123, libopus, libvorbis, lame
|
|
|
|
# Filters
|
|
|
|
, libsamplerate
|
|
|
|
# Outputs
|
2021-10-28 06:52:43 +00:00
|
|
|
, alsa-lib, libjack2, libpulseaudio, libshout, pipewire
|
2020-04-24 23:36:52 +00:00
|
|
|
# Misc
|
2022-01-26 04:04:25 +00:00
|
|
|
, icu, sqlite, avahi, dbus, pcre2, libgcrypt, expat
|
2020-04-24 23:36:52 +00:00
|
|
|
# Services
|
|
|
|
, yajl
|
|
|
|
# Client support
|
2021-02-13 14:23:35 +00:00
|
|
|
, libmpdclient
|
2020-04-24 23:36:52 +00:00
|
|
|
# Tag support
|
|
|
|
, libid3tag
|
|
|
|
, nixosTests
|
2020-06-18 07:06:33 +00:00
|
|
|
# For documentation
|
|
|
|
, doxygen
|
|
|
|
, python3Packages # for sphinx-build
|
|
|
|
# For tests
|
|
|
|
, gtest
|
|
|
|
, zip
|
2020-04-24 23:36:52 +00:00
|
|
|
}:
|
|
|
|
|
|
|
|
let
|
2020-10-07 09:15:18 +00:00
|
|
|
concatAttrVals = nameList: set: lib.concatMap (x: set.${x} or []) nameList;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
featureDependencies = {
|
|
|
|
# Storage plugins
|
|
|
|
udisks = [ dbus ];
|
|
|
|
webdav = [ curl expat ];
|
|
|
|
# Input plugins
|
|
|
|
curl = [ curl ];
|
2020-10-07 09:15:18 +00:00
|
|
|
io_uring = [ liburing ];
|
2020-04-24 23:36:52 +00:00
|
|
|
mms = [ libmms ];
|
|
|
|
nfs = [ libnfs ];
|
|
|
|
smbclient = [ samba ];
|
|
|
|
# Archive support
|
|
|
|
bzip2 = [ bzip2 ];
|
|
|
|
zzip = [ zziplib ];
|
|
|
|
# Decoder plugins
|
|
|
|
audiofile = [ audiofile ];
|
|
|
|
faad = [ faad2 ];
|
2020-07-18 16:06:22 +00:00
|
|
|
ffmpeg = [ ffmpeg ];
|
2020-04-24 23:36:52 +00:00
|
|
|
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
|
2021-06-28 23:13:55 +00:00
|
|
|
alsa = [ alsa-lib ];
|
2020-04-24 23:36:52 +00:00
|
|
|
jack = [ libjack2 ];
|
2021-10-28 06:52:43 +00:00
|
|
|
pipewire = [ pipewire ];
|
2020-04-24 23:36:52 +00:00
|
|
|
pulse = [ libpulseaudio ];
|
|
|
|
shout = [ libshout ];
|
|
|
|
# Commercial services
|
|
|
|
qobuz = [ curl libgcrypt yajl ];
|
|
|
|
soundcloud = [ curl yajl ];
|
|
|
|
# Client support
|
2021-02-13 14:23:35 +00:00
|
|
|
libmpdclient = [ libmpdclient ];
|
2020-04-24 23:36:52 +00:00
|
|
|
# Tag support
|
|
|
|
id3tag = [ libid3tag ];
|
|
|
|
# Misc
|
|
|
|
dbus = [ dbus ];
|
|
|
|
expat = [ expat ];
|
|
|
|
icu = [ icu ];
|
2022-01-26 04:04:25 +00:00
|
|
|
pcre = [ pcre2 ];
|
2020-04-24 23:36:52 +00:00
|
|
|
sqlite = [ sqlite ];
|
|
|
|
syslog = [ ];
|
|
|
|
systemd = [ systemd ];
|
|
|
|
yajl = [ yajl ];
|
|
|
|
zeroconf = [ avahi dbus ];
|
|
|
|
};
|
|
|
|
|
2020-10-07 09:15:18 +00:00
|
|
|
nativeFeatureDependencies = {
|
|
|
|
documentation = [ doxygen python3Packages.sphinx ];
|
|
|
|
};
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
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
|
2022-06-16 17:23:12 +00:00
|
|
|
platformMask = lib.optionals stdenv.isDarwin [ "mad" "pulse" "jack" "smbclient" ]
|
2021-12-06 16:07:01 +00:00
|
|
|
++ lib.optionals (!stdenv.isLinux) [ "alsa" "pipewire" "io_uring" "systemd" "syslog" ];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2020-10-07 09:15:18 +00:00
|
|
|
knownFeatures = builtins.attrNames featureDependencies ++ builtins.attrNames nativeFeatureDependencies;
|
2020-04-24 23:36:52 +00:00
|
|
|
platformFeatures = lib.subtractLists platformMask knownFeatures;
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
in stdenv.mkDerivation rec {
|
|
|
|
pname = "mpd";
|
2022-12-02 08:20:57 +00:00
|
|
|
version = "0.23.11";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "MusicPlayerDaemon";
|
|
|
|
repo = "MPD";
|
|
|
|
rev = "v${version}";
|
2022-12-02 08:20:57 +00:00
|
|
|
sha256 = "sha256-vgLH4kOluK9cOmTrvpBfR87Iunn0EzH9GmiUvsjsG4I=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2020-06-18 07:06:33 +00:00
|
|
|
buildInputs = [
|
|
|
|
glib
|
|
|
|
boost
|
2021-10-28 06:52:43 +00:00
|
|
|
fmt
|
2020-06-18 07:06:33 +00:00
|
|
|
# According to the configurePhase of meson, gtest is considered a
|
|
|
|
# runtime dependency. Quoting:
|
|
|
|
#
|
|
|
|
# Run-time dependency GTest found: YES 1.10.0
|
|
|
|
gtest
|
|
|
|
]
|
2020-10-07 09:15:18 +00:00
|
|
|
++ concatAttrVals features_ featureDependencies
|
2021-06-28 23:13:55 +00:00
|
|
|
++ lib.optionals stdenv.isDarwin [ AudioToolbox AudioUnit ];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2020-06-18 07:06:33 +00:00
|
|
|
nativeBuildInputs = [
|
|
|
|
meson
|
|
|
|
ninja
|
|
|
|
pkg-config
|
2020-10-07 09:15:18 +00:00
|
|
|
]
|
|
|
|
++ concatAttrVals features_ nativeFeatureDependencies;
|
2020-06-18 07:06:33 +00:00
|
|
|
|
2022-09-30 11:47:45 +00:00
|
|
|
depsBuildBuild = [ buildPackages.stdenv.cc ];
|
|
|
|
|
2022-08-12 12:06:08 +00:00
|
|
|
postPatch = lib.optionalString (stdenv.isDarwin && lib.versionOlder stdenv.targetPlatform.darwinSdkVersion "12.0") ''
|
|
|
|
substituteInPlace src/output/plugins/OSXOutputPlugin.cxx \
|
|
|
|
--replace kAudioObjectPropertyElement{Main,Master} \
|
|
|
|
--replace kAudioHardwareServiceDeviceProperty_Virtual{Main,Master}Volume
|
|
|
|
'';
|
|
|
|
|
2020-06-18 07:06:33 +00:00
|
|
|
# Otherwise, the meson log says:
|
|
|
|
#
|
|
|
|
# Program zip found: NO
|
|
|
|
checkInputs = [ zip ];
|
|
|
|
|
|
|
|
doCheck = true;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
mesonAutoFeatures = "disabled";
|
2020-06-18 07:06:33 +00:00
|
|
|
|
2020-10-27 00:29:36 +00:00
|
|
|
outputs = [ "out" "doc" ]
|
|
|
|
++ lib.optional (builtins.elem "documentation" features_) "man";
|
2020-06-18 07:06:33 +00:00
|
|
|
|
2022-02-20 05:27:41 +00:00
|
|
|
CXXFLAGS = lib.optionals stdenv.isDarwin [
|
|
|
|
"-D__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES=0"
|
|
|
|
];
|
|
|
|
|
2020-06-18 07:06:33 +00:00
|
|
|
mesonFlags = [
|
|
|
|
"-Dtest=true"
|
2020-10-07 09:15:18 +00:00
|
|
|
"-Dmanpages=true"
|
|
|
|
"-Dhtml_manual=true"
|
2020-06-18 07:06:33 +00:00
|
|
|
]
|
|
|
|
++ map (x: "-D${x}=enabled") features_
|
2020-04-24 23:36:52 +00:00
|
|
|
++ 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";
|
|
|
|
|
|
|
|
passthru.tests.nixos = nixosTests.mpd;
|
|
|
|
|
2021-01-15 22:18:51 +00:00
|
|
|
meta = with lib; {
|
2020-04-24 23:36:52 +00:00
|
|
|
description = "A flexible, powerful daemon for playing music";
|
|
|
|
homepage = "https://www.musicpd.org/";
|
2021-03-09 03:18:52 +00:00
|
|
|
license = licenses.gpl2Only;
|
2022-08-12 12:06:08 +00:00
|
|
|
maintainers = with maintainers; [ astsmtl ehmry tobim ];
|
2020-04-24 23:36:52 +00:00
|
|
|
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 = [
|
2022-06-16 17:23:12 +00:00
|
|
|
"webdav" "curl" "mms" "bzip2" "zzip" "nfs"
|
2021-01-05 17:05:55 +00:00
|
|
|
"audiofile" "faad" "flac" "gme"
|
2020-04-24 23:36:52 +00:00
|
|
|
"mpg123" "opus" "vorbis" "vorbisenc"
|
|
|
|
"lame" "libsamplerate" "shout"
|
|
|
|
"libmpdclient" "id3tag" "expat" "pcre"
|
|
|
|
"yajl" "sqlite"
|
2022-01-23 02:10:13 +00:00
|
|
|
"soundcloud" "qobuz"
|
2020-04-24 23:36:52 +00:00
|
|
|
] ++ lib.optionals stdenv.isLinux [
|
2020-10-07 09:15:18 +00:00
|
|
|
"alsa" "systemd" "syslog" "io_uring"
|
2020-04-24 23:36:52 +00:00
|
|
|
] ++ lib.optionals (!stdenv.isDarwin) [
|
2022-06-16 17:23:12 +00:00
|
|
|
"mad" "jack"
|
2020-04-24 23:36:52 +00:00
|
|
|
]; };
|
|
|
|
mpdWithFeatures = run;
|
|
|
|
}
|