@@ -1,4 +1,95 @@
1−{ stdenv, fetchFromGitHub, ncurses, pkgconfig, alsaLib, flac, libmad, ffmpeg, libvorbis, libmpc, mp4v2, libcue, libpulseaudio}:
1+{ stdenv, fetchFromGitHub, ncurses, pkgconfig
2+
3+, alsaSupport ? stdenv.isLinux, alsaLib ? null
4+# simple fallback for everyone else
5+, aoSupport ? !stdenv.isLinux, libao ? null
6+, jackSupport ? false, libjack ? null
7+, samplerateSupport ? jackSupport, libsamplerate ? null
8+, ossSupport ? false, alsaOss ? null
9+, pulseaudioSupport ? false, libpulseaudio ? null
10+
11+# TODO: add these
12+#, artsSupport
13+#, roarSupport
14+#, sndioSupport
15+#, sunSupport
16+#, waveoutSupport
17+
18+, cddbSupport ? true, libcddb ? null
19+, cdioSupport ? true, libcdio ? null
20+, cueSupport ? true, libcue ? null
21+, discidSupport ? true, libdiscid ? null
22+, ffmpegSupport ? true, ffmpeg ? null
23+, flacSupport ? true, flac ? null
24+, madSupport ? true, libmad ? null
25+, mikmodSupport ? true, libmikmod ? null
26+, modplugSupport ? true, libmodplug ? null
27+, mpcSupport ? true, libmpcdec ? null
28+, tremorSupport ? false, tremor ? null
29+, vorbisSupport ? true, libvorbis ? null
30+, wavpackSupport ? true, wavpack ? null
31+
32+# can't make these work, something is broken
33+#, aacSupport ? true, faac ? null
34+#, mp4Support ? true, mp4v2 ? null
35+#, opusSupport ? true, opusfile ? null
36+
37+# not in nixpkgs
38+#, vtxSupport ? true, libayemu ? null
39+}:
40+
41+with stdenv.lib;
42+
43+assert samplerateSupport -> jackSupport;
44+
45+# vorbis and tremor are mutually exclusive
46+assert vorbisSupport -> !tremorSupport;
47+assert tremorSupport -> !vorbisSupport;
48+
49+let
50+
51+ mkFlag = b: f: dep: if b
52+ then { flags = [ f ]; deps = [ dep ]; }
53+ else { flags = []; deps = []; };
54+
55+ opts = [
56+ # Audio output
57+ (mkFlag alsaSupport "CONFIG_ALSA=y" alsaLib)
58+ (mkFlag aoSupport "CONFIG_AO=y" libao)
59+ (mkFlag jackSupport "CONFIG_JACK=y" libjack)
60+ (mkFlag samplerateSupport "CONFIG_SAMPLERATE=y" libsamplerate)
61+ (mkFlag ossSupport "CONFIG_OSS=y" alsaOss)
62+ (mkFlag pulseaudioSupport "CONFIG_PULSE=y" libpulseaudio)
63+
64+ #(mkFlag artsSupport "CONFIG_ARTS=y")
65+ #(mkFlag roarSupport "CONFIG_ROAR=y")
66+ #(mkFlag sndioSupport "CONFIG_SNDIO=y")
67+ #(mkFlag sunSupport "CONFIG_SUN=y")
68+ #(mkFlag waveoutSupport "CONFIG_WAVEOUT=y")
69+
70+ # Input file formats
71+ (mkFlag cddbSupport "CONFIG_CDDB=y" libcddb)
72+ (mkFlag cdioSupport "CONFIG_CDIO=y" libcdio)
73+ (mkFlag cueSupport "CONFIG_CUE=y" libcue)
74+ (mkFlag discidSupport "CONFIG_DISCID=y" libdiscid)
75+ (mkFlag ffmpegSupport "CONFIG_FFMPEG=y" ffmpeg)
76+ (mkFlag flacSupport "CONFIG_FLAC=y" flac)
77+ (mkFlag madSupport "CONFIG_MAD=y" libmad)
78+ (mkFlag mikmodSupport "CONFIG_MIKMOD=y" libmikmod)
79+ (mkFlag modplugSupport "CONFIG_MODPLUG=y" libmodplug)
80+ (mkFlag mpcSupport "CONFIG_MPC=y" libmpcdec)
81+ (mkFlag tremorSupport "CONFIG_TREMOR=y" tremor)
82+ (mkFlag vorbisSupport "CONFIG_VORBIS=y" libvorbis)
83+ (mkFlag wavpackSupport "CONFIG_WAVPACK=y" wavpack)
84+
85+ #(mkFlag opusSupport "CONFIG_OPUS=y" opusfile)
86+ #(mkFlag mp4Support "CONFIG_MP4=y" mp4v2)
87+ #(mkFlag aacSupport "CONFIG_AAC=y" faac)
88+
89+ #(mkFlag vtxSupport "CONFIG_VTX=y" libayemu)
90+ ];
91+
92+in
293
394stdenv.mkDerivation rec {
495 name = "cmus-${version}";
@@ -11,9 +102,14 @@ stdenv.mkDerivation rec {
11102 sha256 = "18w9mznb843nzkrcqvshfha51mlpdl92zlvb5wfc5dpgrbf37728";
12103 };
13104
14− configurePhase = "./configure prefix=$out";
105+ patches = [ ./option-debugging.patch ];
106+
107+ configurePhase = "./configure " + concatStringsSep " " ([
108+ "prefix=$out"
109+ "CONFIG_WAV=y"
110+ ] ++ concatMap (a: a.flags) opts);
15111
16− buildInputs = [ ncurses pkgconfig alsaLib flac libmad ffmpeg libvorbis libmpc mp4v2 libcue libpulseaudio ];
112+ buildInputs = [ ncurses pkgconfig ] ++ concatMap (a: a.deps) opts;
17113
18114 meta = {
19115 description = "Small, fast and powerful console music player for Linux and *BSD";