nixpkgs/pkgs/servers/mpd/default.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

221 lines
6.8 KiB
Nix
Raw Normal View History

2022-09-07 19:05:11 +00:00
{ lib, stdenv, fetchFromGitHub, meson, ninja, pkg-config, glib, systemd, boost, fmt, buildPackages
2021-06-04 14:37:27 +00:00
# Darwin inputs
, AudioToolbox, AudioUnit
# Inputs
2020-09-26 15:38:36 +00:00
, curl, libmms, libnfs, liburing, samba
# Archive support
, bzip2, zziplib
# Codecs
2020-07-02 18:10:47 +00:00
, audiofile, faad2, ffmpeg, flac, fluidsynth, game-music-emu
, libmad, libmikmod, mpg123, libopus, libvorbis, lame
# Filters
, libsamplerate
# Outputs
, alsa-lib, libjack2, libpulseaudio, libshout, pipewire
# Misc
2022-01-25 02:18:54 +00:00
, icu, sqlite, avahi, dbus, pcre2, libgcrypt, expat
# Services
, yajl
# Client support
2021-02-12 11:28:36 +00:00
, libmpdclient
# Tag support
, libid3tag
2020-04-16 07:22:28 +00:00
, nixosTests
# For documentation
, doxygen
, python3Packages # for sphinx-build
2020-05-16 14:08:05 +00:00
# For tests
, gtest
, zip
2014-06-01 15:07:46 +00:00
}:
let
2020-09-26 15:38:36 +00:00
concatAttrVals = nameList: set: lib.concatMap (x: set.${x} or []) nameList;
featureDependencies = {
# Storage plugins
udisks = [ dbus ];
webdav = [ curl expat ];
# Input plugins
curl = [ curl ];
2020-09-26 15:38:36 +00:00
io_uring = [ liburing ];
mms = [ libmms ];
nfs = [ libnfs ];
smbclient = [ samba ];
# Archive support
bzip2 = [ bzip2 ];
zzip = [ zziplib ];
# Decoder plugins
audiofile = [ audiofile ];
faad = [ faad2 ];
2020-07-02 18:10:47 +00:00
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 = [ alsa-lib ];
jack = [ libjack2 ];
pipewire = [ pipewire ];
pulse = [ libpulseaudio ];
shout = [ libshout ];
# Commercial services
qobuz = [ curl libgcrypt yajl ];
soundcloud = [ curl yajl ];
# Client support
2021-02-12 11:28:36 +00:00
libmpdclient = [ libmpdclient ];
# Tag support
id3tag = [ libid3tag ];
# Misc
dbus = [ dbus ];
expat = [ expat ];
icu = [ icu ];
2022-01-25 02:18:54 +00:00
pcre = [ pcre2 ];
sqlite = [ sqlite ];
syslog = [ ];
systemd = [ systemd ];
yajl = [ yajl ];
zeroconf = [ avahi dbus ];
};
2012-10-25 01:15:48 +00:00
2020-09-26 15:38:36 +00:00
nativeFeatureDependencies = {
documentation = [ doxygen python3Packages.sphinx ];
};
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" "smbclient" ]
++ lib.optionals (!stdenv.isLinux) [ "alsa" "pipewire" "io_uring" "systemd" "syslog" ];
2020-09-26 15:38:36 +00:00
knownFeatures = builtins.attrNames featureDependencies ++ builtins.attrNames nativeFeatureDependencies;
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-01 15:43:25 +00:00
version = "0.23.11";
src = fetchFromGitHub {
owner = "MusicPlayerDaemon";
repo = "MPD";
rev = "v${version}";
2022-12-01 15:43:25 +00:00
sha256 = "sha256-vgLH4kOluK9cOmTrvpBfR87Iunn0EzH9GmiUvsjsG4I=";
};
2012-10-25 01:15:48 +00:00
2020-05-16 14:06:55 +00:00
buildInputs = [
glib
boost
fmt
2020-05-16 14:08:05 +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-05-16 14:06:55 +00:00
]
2020-09-26 15:38:36 +00:00
++ concatAttrVals features_ featureDependencies
2021-06-04 14:37:27 +00:00
++ lib.optionals stdenv.isDarwin [ AudioToolbox AudioUnit ];
2012-10-25 01:15:48 +00:00
2020-05-16 14:06:55 +00:00
nativeBuildInputs = [
meson
ninja
pkg-config
2020-09-26 15:38:36 +00:00
]
++ concatAttrVals features_ nativeFeatureDependencies;
2022-09-07 19:05:11 +00:00
depsBuildBuild = [ buildPackages.stdenv.cc ];
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-05-16 14:08:05 +00:00
# Otherwise, the meson log says:
#
# Program zip found: NO
checkInputs = [ zip ];
doCheck = true;
mesonAutoFeatures = "disabled";
2020-05-16 14:08:05 +00:00
outputs = [ "out" "doc" ]
++ lib.optional (builtins.elem "documentation" features_) "man";
2023-01-15 11:09:16 +00:00
# FIXME: workaround for Pipewire 0.3.64 deprecated API change, remove when fixed upstream
NIX_CFLAGS_COMPILE = [ "-DPW_ENABLE_DEPRECATED" ];
CXXFLAGS = lib.optionals stdenv.isDarwin [
"-D__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES=0"
];
2020-05-16 14:08:05 +00:00
mesonFlags = [
"-Dtest=true"
2020-09-26 15:38:36 +00:00
"-Dmanpages=true"
"-Dhtml_manual=true"
2020-05-16 14:08:05 +00:00
]
++ 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";
2020-04-16 07:22:28 +00:00
passthru.tests.nixos = nixosTests.mpd;
meta = with lib; {
description = "A flexible, powerful daemon for playing music";
2020-03-02 15:30:28 +00:00
homepage = "https://www.musicpd.org/";
2021-02-26 07:49:51 +00:00
license = licenses.gpl2Only;
maintainers = with maintainers; [ astsmtl ehmry 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" "nfs"
"audiofile" "faad" "flac" "gme"
"mpg123" "opus" "vorbis" "vorbisenc"
"lame" "libsamplerate" "shout"
"libmpdclient" "id3tag" "expat" "pcre"
"yajl" "sqlite"
2022-01-22 11:54:16 +00:00
"soundcloud" "qobuz"
] ++ lib.optionals stdenv.isLinux [
2020-09-26 15:38:36 +00:00
"alsa" "systemd" "syslog" "io_uring"
] ++ lib.optionals (!stdenv.isDarwin) [
"mad" "jack"
]; };
mpdWithFeatures = run;
}