]>
Commit | Line | Data |
---|---|---|
65e64925 IB |
1 | { stdenv, fetchFromGitHub, meson, ninja, pkgconfig, glib, systemd, boost, darwin |
2 | # Inputs | |
3 | , curl, libmms, libnfs, samba | |
4 | # Archive support | |
5 | , bzip2, zziplib | |
6 | # Codecs | |
7 | , audiofile, faad2, ffmpeg, flac, fluidsynth, game-music-emu | |
8 | , libmad, libmikmod, mpg123, libopus, libvorbis, lame | |
9 | # Filters | |
10 | , libsamplerate | |
11 | # Outputs | |
12 | , alsaLib, libjack2, libpulseaudio, libshout | |
13 | # Misc | |
14 | , icu, sqlite, avahi, dbus, pcre, libgcrypt, expat | |
15 | # Services | |
16 | , yajl | |
17 | # Client support | |
18 | , mpd_clientlib | |
19 | # Tag support | |
20 | , libid3tag | |
21 | }: | |
22 | ||
23 | let | |
24 | major = "0.21"; | |
25 | minor = "7"; | |
26 | ||
27 | lib = stdenv.lib; | |
28 | mkDisable = f: "-D${f}=disabled"; | |
29 | mkEnable = f: "-D${f}=enabled"; | |
30 | keys = lib.mapAttrsToList (k: v: k); | |
31 | ||
32 | featureDependencies = { | |
33 | # Storage plugins | |
34 | udisks = [ dbus ]; | |
35 | webdav = [ curl expat ]; | |
36 | # Input plugins | |
37 | curl = [ curl ]; | |
38 | mms = [ libmms ]; | |
39 | nfs = [ libnfs ]; | |
40 | smbclient = [ samba ]; | |
41 | # Archive support | |
42 | bzip2 = [ bzip2 ]; | |
43 | zzip = [ zziplib ]; | |
44 | # Decoder plugins | |
45 | audiofile = [ audiofile ]; | |
46 | faad = [ faad2 ]; | |
47 | ffmpeg = [ ffmpeg ]; | |
48 | flac = [ flac ]; | |
49 | fluidsynth = [ fluidsynth ]; | |
50 | gme = [ game-music-emu ]; | |
51 | mad = [ libmad ]; | |
52 | mikmod = [ libmikmod ]; | |
53 | mpg123 = [ mpg123 ]; | |
54 | opus = [ libopus ]; | |
55 | vorbis = [ libvorbis ]; | |
56 | # Encoder plugins | |
57 | vorbisenc = [ libvorbis ]; | |
58 | lame = [ lame ]; | |
59 | # Filter plugins | |
60 | libsamplerate = [ libsamplerate ]; | |
61 | # Output plugins | |
62 | alsa = [ alsaLib ]; | |
63 | jack = [ libjack2 ]; | |
64 | pulse = [ libpulseaudio ]; | |
65 | shout = [ libshout ]; | |
66 | # Commercial services | |
67 | qobuz = [ curl libgcrypt yajl ]; | |
68 | soundcloud = [ curl yajl ]; | |
69 | tidal = [ curl yajl ]; | |
70 | # Client support | |
71 | libmpdclient = [ mpd_clientlib ]; | |
72 | # Tag support | |
73 | id3tag = [ libid3tag ]; | |
74 | # Misc | |
75 | dbus = [ dbus ]; | |
76 | expat = [ expat ]; | |
77 | icu = [ icu ]; | |
78 | pcre = [ pcre ]; | |
79 | sqlite = [ sqlite ]; | |
80 | systemd = [ systemd ]; | |
81 | yajl = [ yajl ]; | |
82 | zeroconf = [ avahi dbus ]; | |
83 | }; | |
84 | ||
85 | run = { features ? null }: | |
86 | let | |
87 | fl = if (features == null ) | |
88 | then keys featureDependencies | |
89 | else features; | |
90 | ||
91 | # Disable platform specific features if needed | |
92 | # using libmad to decode mp3 files on darwin is causing a segfault -- there | |
93 | # is probably a solution, but I'm disabling it for now | |
94 | platformMask = lib.optionals stdenv.isDarwin [ "mad" "pulse" "jack" "nfs" "smb" ] | |
95 | ++ lib.optionals (!stdenv.isLinux) [ "alsa" "systemd" ]; | |
96 | features_ = lib.subtractLists platformMask fl; | |
97 | ||
98 | in stdenv.mkDerivation rec { | |
99 | name = "mpd-${version}"; | |
100 | version = "${major}${if minor == "" then "" else "." + minor}"; | |
101 | ||
102 | src = fetchFromGitHub { | |
103 | owner = "MusicPlayerDaemon"; | |
104 | repo = "MPD"; | |
105 | rev = "v${version}"; | |
106 | sha256 = "11zi8hmlj63ngzl06vzx05669k20j4cdsp0caz4p4ayn46fd4m17"; | |
107 | }; | |
108 | ||
109 | buildInputs = [ glib boost ] | |
110 | ++ (lib.concatLists (lib.attrVals features_ featureDependencies)) | |
111 | ++ lib.optional stdenv.isDarwin darwin.apple_sdk.frameworks.AudioToolbox; | |
112 | ||
113 | nativeBuildInputs = [ meson ninja pkgconfig ]; | |
114 | ||
115 | enableParallelBuilding = true; | |
116 | ||
117 | mesonFlags = | |
118 | map mkEnable features_ ++ map mkDisable (lib.subtractLists features_ (keys featureDependencies)) | |
119 | ++ [ "-Dsyslog=enabled" ] | |
120 | ++ lib.optional (lib.any (x: x == "zeroconf") features_) | |
121 | "-Dzeroconf=avahi" | |
122 | ++ lib.optional stdenv.isLinux | |
123 | "-Dsystemd_system_unit_dir=etc/systemd/system"; | |
124 | ||
125 | meta = with stdenv.lib; { | |
126 | description = "A flexible, powerful daemon for playing music"; | |
127 | homepage = http://mpd.wikia.com/wiki/Music_Player_Daemon_Wiki; | |
128 | license = licenses.gpl2; | |
129 | maintainers = with maintainers; [ astsmtl fuuzetsu ehmry fpletz ]; | |
130 | platforms = platforms.unix; | |
131 | ||
132 | longDescription = '' | |
133 | Music Player Daemon (MPD) is a flexible, powerful daemon for playing | |
134 | music. Through plugins and libraries it can play a variety of sound | |
135 | files while being controlled by its network protocol. | |
136 | ''; | |
137 | }; | |
138 | }; | |
139 | in | |
140 | { | |
141 | mpd = run { }; | |
142 | mpd-small = run { features = [ | |
143 | "webdav" "curl" "mms" "nfs" "bzip2" "zzip" | |
144 | "audiofile" "faad" "flac" "gme" "mad" | |
145 | "mpg123" "opus" "vorbis" | |
146 | "vorbisenc" "lame" "libsamplerate" | |
147 | "alsa" "shout" "libmpdclient" | |
148 | "id3tag" "expat" "pcre" "yajl" "sqlite" | |
149 | "soundcloud" "qobuz" "tidal" | |
150 | "systemd" | |
151 | ]; }; | |
152 | } |