|
| 1 | +{ |
| 2 | + stdenv, |
| 3 | + lib, |
| 4 | + fetchFromGitHub, |
| 5 | + cmake, |
| 6 | + pkg-config, |
| 7 | + qt5, |
| 8 | + perl, |
| 9 | + |
| 10 | + # Cantata doesn't build with cdparanoia enabled so we disable that |
| 11 | + # default for now until I (or someone else) figure it out. |
| 12 | + withCdda ? false, |
| 13 | + cdparanoia, |
| 14 | + withCddb ? false, |
| 15 | + libcddb, |
| 16 | + withLame ? false, |
| 17 | + lame, |
| 18 | + withMusicbrainz ? false, |
| 19 | + libmusicbrainz5, |
| 20 | + |
| 21 | + withTaglib ? true, |
| 22 | + taglib, |
| 23 | + taglib_extras, |
| 24 | + withHttpStream ? true, |
| 25 | + withReplaygain ? true, |
| 26 | + ffmpeg, |
| 27 | + speex, |
| 28 | + mpg123, |
| 29 | + withMtp ? true, |
| 30 | + libmtp, |
| 31 | + withOnlineServices ? true, |
| 32 | + withDevices ? true, |
| 33 | + udisks2, |
| 34 | + withDynamic ? true, |
| 35 | + withHttpServer ? true, |
| 36 | + withLibVlc ? false, |
| 37 | + libvlc, |
| 38 | + withStreams ? true, |
| 39 | +}: |
| 40 | + |
| 41 | +# Inter-dependencies. |
| 42 | +assert withCddb -> withCdda && withTaglib; |
| 43 | +assert withCdda -> withCddb && withMusicbrainz; |
| 44 | +assert withLame -> withCdda && withTaglib; |
| 45 | +assert withMtp -> withTaglib; |
| 46 | +assert withMusicbrainz -> withCdda && withTaglib; |
| 47 | +assert withOnlineServices -> withTaglib; |
| 48 | +assert withReplaygain -> withTaglib; |
| 49 | +assert withLibVlc -> withHttpStream; |
| 50 | + |
| 51 | +let |
| 52 | + fstat = x: fn: "-DENABLE_${fn}=${if x then "ON" else "OFF"}"; |
| 53 | + |
| 54 | + withUdisks = (withTaglib && withDevices && stdenv.hostPlatform.isLinux); |
| 55 | + |
| 56 | + options = [ |
| 57 | + { |
| 58 | + names = [ "CDDB" ]; |
| 59 | + enable = withCddb; |
| 60 | + pkgs = [ libcddb ]; |
| 61 | + } |
| 62 | + { |
| 63 | + names = [ "CDPARANOIA" ]; |
| 64 | + enable = withCdda; |
| 65 | + pkgs = [ cdparanoia ]; |
| 66 | + } |
| 67 | + { |
| 68 | + names = [ "DEVICES_SUPPORT" ]; |
| 69 | + enable = withDevices; |
| 70 | + pkgs = [ ]; |
| 71 | + } |
| 72 | + { |
| 73 | + names = [ "DYNAMIC" ]; |
| 74 | + enable = withDynamic; |
| 75 | + pkgs = [ ]; |
| 76 | + } |
| 77 | + { |
| 78 | + names = [ |
| 79 | + "FFMPEG" |
| 80 | + "MPG123" |
| 81 | + "SPEEXDSP" |
| 82 | + ]; |
| 83 | + enable = withReplaygain; |
| 84 | + pkgs = [ |
| 85 | + ffmpeg |
| 86 | + speex |
| 87 | + mpg123 |
| 88 | + ]; |
| 89 | + } |
| 90 | + { |
| 91 | + names = [ "HTTPS_SUPPORT" ]; |
| 92 | + enable = true; |
| 93 | + pkgs = [ ]; |
| 94 | + } |
| 95 | + { |
| 96 | + names = [ "HTTP_SERVER" ]; |
| 97 | + enable = withHttpServer; |
| 98 | + pkgs = [ ]; |
| 99 | + } |
| 100 | + { |
| 101 | + names = [ "HTTP_STREAM_PLAYBACK" ]; |
| 102 | + enable = withHttpStream; |
| 103 | + pkgs = [ qt5.qtmultimedia ]; |
| 104 | + } |
| 105 | + { |
| 106 | + names = [ "LAME" ]; |
| 107 | + enable = withLame; |
| 108 | + pkgs = [ lame ]; |
| 109 | + } |
| 110 | + { |
| 111 | + names = [ "LIBVLC" ]; |
| 112 | + enable = withLibVlc; |
| 113 | + pkgs = [ libvlc ]; |
| 114 | + } |
| 115 | + { |
| 116 | + names = [ "MTP" ]; |
| 117 | + enable = withMtp; |
| 118 | + pkgs = [ libmtp ]; |
| 119 | + } |
| 120 | + { |
| 121 | + names = [ "MUSICBRAINZ" ]; |
| 122 | + enable = withMusicbrainz; |
| 123 | + pkgs = [ libmusicbrainz5 ]; |
| 124 | + } |
| 125 | + { |
| 126 | + names = [ "ONLINE_SERVICES" ]; |
| 127 | + enable = withOnlineServices; |
| 128 | + pkgs = [ ]; |
| 129 | + } |
| 130 | + { |
| 131 | + names = [ "STREAMS" ]; |
| 132 | + enable = withStreams; |
| 133 | + pkgs = [ ]; |
| 134 | + } |
| 135 | + { |
| 136 | + names = [ |
| 137 | + "TAGLIB" |
| 138 | + "TAGLIB_EXTRAS" |
| 139 | + ]; |
| 140 | + enable = withTaglib; |
| 141 | + pkgs = [ |
| 142 | + taglib |
| 143 | + taglib_extras |
| 144 | + ]; |
| 145 | + } |
| 146 | + { |
| 147 | + names = [ "UDISKS2" ]; |
| 148 | + enable = withUdisks; |
| 149 | + pkgs = [ udisks2 ]; |
| 150 | + } |
| 151 | + ]; |
| 152 | + |
| 153 | +in |
| 154 | +stdenv.mkDerivation (finalAttrs: { |
| 155 | + pname = "cantata"; |
| 156 | + version = "2.5.0"; |
| 157 | + |
| 158 | + src = fetchFromGitHub { |
| 159 | + owner = "CDrummond"; |
| 160 | + repo = "cantata"; |
| 161 | + rev = "v${finalAttrs.version}"; |
| 162 | + hash = "sha256-UaZEKZvCA50WsdQSSJQQ11KTK6rM4ouCHDX7pn3NlQw="; |
| 163 | + }; |
| 164 | + |
| 165 | + patches = [ |
| 166 | + # Cantata wants to check if perl is in the PATH at runtime, but we |
| 167 | + # patchShebangs the playlists scripts, making that unnecessary (perl will |
| 168 | + # always be available because it's a dependency) |
| 169 | + ./dont-check-for-perl-in-PATH.diff |
| 170 | + ]; |
| 171 | + |
| 172 | + postPatch = '' |
| 173 | + patchShebangs playlists |
| 174 | + ''; |
| 175 | + |
| 176 | + buildInputs = [ |
| 177 | + qt5.qtbase |
| 178 | + qt5.qtsvg |
| 179 | + (perl.withPackages (ppkgs: with ppkgs; [ URI ])) |
| 180 | + ] ++ lib.flatten (builtins.catAttrs "pkgs" (builtins.filter (e: e.enable) options)); |
| 181 | + |
| 182 | + nativeBuildInputs = [ |
| 183 | + cmake |
| 184 | + pkg-config |
| 185 | + qt5.qttools |
| 186 | + qt5.wrapQtAppsHook |
| 187 | + ]; |
| 188 | + |
| 189 | + cmakeFlags = lib.flatten (map (e: map (f: fstat e.enable f) e.names) options); |
| 190 | + |
| 191 | + meta = { |
| 192 | + description = "Graphical client for MPD"; |
| 193 | + mainProgram = "cantata"; |
| 194 | + homepage = "https://github.com/cdrummond/cantata"; |
| 195 | + license = lib.licenses.gpl3Only; |
| 196 | + maintainers = with lib.maintainers; [ peterhoeg ]; |
| 197 | + # Technically, Cantata should run on Darwin/Windows so if someone wants to |
| 198 | + # bother figuring that one out, be my guest. |
| 199 | + platforms = lib.platforms.unix; |
| 200 | + badPlatforms = lib.platforms.darwin; |
| 201 | + }; |
| 202 | +}) |
0 commit comments