1 { config, lib, stdenv, fetchFromGitHub, ncurses, pkg-config
2 , libiconv, CoreAudio, AudioUnit, VideoToolbox
4 , alsaSupport ? stdenv.hostPlatform.isLinux, alsa-lib ? null
5 # simple fallback for everyone else
6 , aoSupport ? !stdenv.hostPlatform.isLinux, libao ? null
7 , jackSupport ? false, libjack ? null
8 , samplerateSupport ? jackSupport, libsamplerate ? null
9 , ossSupport ? false, alsa-oss ? null
10 , pulseaudioSupport ? config.pulseaudio or false, libpulseaudio ? null
11 , sndioSupport ? false, sndio ? null
12 , mprisSupport ? stdenv.hostPlatform.isLinux, systemd ? null
20 , cddbSupport ? true, libcddb ? null
21 , cdioSupport ? true, libcdio ? null, libcdio-paranoia ? null
22 , cueSupport ? true, libcue ? null
23 , discidSupport ? false, libdiscid ? null
24 , ffmpegSupport ? true, ffmpeg ? null
25 , flacSupport ? true, flac ? null
26 , madSupport ? true, libmad ? null
27 , mikmodSupport ? true, libmikmod ? null
28 , modplugSupport ? true, libmodplug ? null
29 , mpcSupport ? true, libmpcdec ? null
30 , tremorSupport ? false, tremor ? null
31 , vorbisSupport ? true, libvorbis ? null
32 , wavpackSupport ? true, wavpack ? null
33 , opusSupport ? true, opusfile ? null
35 , aacSupport ? false, faad2 ? null # already handled by ffmpeg
36 , mp4Support ? false, mp4v2 ? null # ffmpeg does support mp4 better
39 #, vtxSupport ? true, libayemu ? null
42 assert samplerateSupport -> jackSupport;
44 # vorbis and tremor are mutually exclusive
45 assert vorbisSupport -> !tremorSupport;
46 assert tremorSupport -> !vorbisSupport;
50 mkFlag = b: f: dep: if b
51 then { flags = [ f ]; deps = [ dep ]; }
52 else { flags = []; deps = []; };
56 (mkFlag alsaSupport "CONFIG_ALSA=y" alsa-lib)
57 (mkFlag aoSupport "CONFIG_AO=y" libao)
58 (mkFlag jackSupport "CONFIG_JACK=y" libjack)
59 (mkFlag samplerateSupport "CONFIG_SAMPLERATE=y" libsamplerate)
60 (mkFlag ossSupport "CONFIG_OSS=y" alsa-oss)
61 (mkFlag pulseaudioSupport "CONFIG_PULSE=y" libpulseaudio)
62 (mkFlag sndioSupport "CONFIG_SNDIO=y" sndio)
63 (mkFlag mprisSupport "CONFIG_MPRIS=y" systemd)
65 #(mkFlag artsSupport "CONFIG_ARTS=y")
66 #(mkFlag roarSupport "CONFIG_ROAR=y")
67 #(mkFlag sunSupport "CONFIG_SUN=y")
68 #(mkFlag waveoutSupport "CONFIG_WAVEOUT=y")
71 (mkFlag cddbSupport "CONFIG_CDDB=y" libcddb)
72 (mkFlag cdioSupport "CONFIG_CDIO=y" [ libcdio libcdio-paranoia ])
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 (mkFlag opusSupport "CONFIG_OPUS=y" opusfile)
86 (mkFlag mp4Support "CONFIG_MP4=y" mp4v2)
87 (mkFlag aacSupport "CONFIG_AAC=y" faad2)
89 #(mkFlag vtxSupport "CONFIG_VTX=y" libayemu)
93 stdenv.mkDerivation rec {
97 src = fetchFromGitHub {
101 hash = "sha256-8hgibGtkiwzenMI9YImIApRmw2EzTwE6RhglALpUkp4=";
104 nativeBuildInputs = [ pkg-config ];
105 buildInputs = [ ncurses ]
106 ++ lib.optionals stdenv.hostPlatform.isDarwin [ libiconv CoreAudio AudioUnit VideoToolbox ]
107 ++ lib.flatten (lib.concatMap (a: a.deps) opts);
109 prefixKey = "prefix=";
113 "HOSTCC=${stdenv.cc.targetPrefix}cc"
114 ] ++ lib.concatMap (a: a.flags) opts;
116 makeFlags = [ "LD=$(CC)" ];
119 description = "Small, fast and powerful console music player for Linux and *BSD";
120 homepage = "https://cmus.github.io/";
121 license = licenses.gpl2;
122 maintainers = [ maintainers.oxij ];
123 platforms = platforms.linux ++ platforms.darwin;