1 { stdenv, lib, fetchFromGitHub, writeScript, glibcLocales, diffPlugins, substituteAll
2 , pythonPackages, imagemagick, gobject-introspection, gst_all_1
3 , runtimeShell, unstableGitUpdater
5 # external plugins package set
8 , enableAbsubmit ? lib.elem stdenv.hostPlatform.system essentia-extractor.meta.platforms, essentia-extractor
9 , enableAcousticbrainz ? true
10 , enableAcoustid ? true
12 , enableBadfiles ? true, flac, mp3val
13 , enableBeatport ? true
15 , enableConvert ? true, ffmpeg
17 , enableDiscogs ? true
18 , enableEmbyupdate ? true
19 , enableFetchart ? true
20 , enableKeyfinder ? true, keyfinder-cli
21 , enableKodiupdate ? true
23 , enableLoadext ? true
26 , enablePlaylist ? true
27 , enableReplaygain ? true
28 , enableSonosUpdate ? true
29 , enableSubsonicplaylist ? true
30 , enableSubsonicupdate ? true
31 , enableThumbnails ? true
35 , enableAlternatives ? false
36 , enableCopyArtifacts ? false
37 , enableExtraFiles ? false
39 , bashInteractive, bash-completion
42 assert enableBpsync -> enableBeatport;
46 absubmit = enableAbsubmit;
47 acousticbrainz = enableAcousticbrainz;
49 badfiles = enableBadfiles;
50 beatport = enableBeatport;
51 bpsync = enableBpsync;
52 chroma = enableAcoustid;
53 convert = enableConvert;
54 deezer = enableDeezer;
55 discogs = enableDiscogs;
56 embyupdate = enableEmbyupdate;
57 fetchart = enableFetchart;
58 keyfinder = enableKeyfinder;
59 kodiupdate = enableKodiupdate;
60 lastgenre = enableLastfm;
61 lastimport = enableLastfm;
62 loadext = enableLoadext;
63 lyrics = enableLyrics;
65 mpdupdate = enableMpd;
66 playlist = enablePlaylist;
67 replaygain = enableReplaygain;
68 sonosupdate = enableSonosUpdate;
69 subsonicplaylist = enableSubsonicplaylist;
70 subsonicupdate = enableSubsonicupdate;
71 thumbnails = enableThumbnails;
75 pluginsWithoutDeps = [
76 "bareasc" "bench" "bpd" "bpm" "bucket" "duplicates" "edit" "embedart"
77 "export" "filefilter" "fish" "freedesktop" "fromfilename" "ftintitle" "fuzzy"
78 "hook" "ihate" "importadded" "importfeeds" "info" "inline" "ipfs"
79 "mbcollection" "mbsubmit" "mbsync" "metasync" "missing" "parentwork" "permissions" "play"
80 "plexupdate" "random" "rewrite" "scrub" "smartplaylist" "spotify" "the"
81 "types" "unimported" "zero"
84 enabledOptionalPlugins = lib.attrNames (lib.filterAttrs (_: lib.id) optionalPlugins);
86 allPlugins = pluginsWithoutDeps ++ lib.attrNames optionalPlugins;
87 allEnabledPlugins = pluginsWithoutDeps ++ enabledOptionalPlugins;
89 testShell = "${bashInteractive}/bin/bash --norc";
90 completion = "${bash-completion}/share/bash-completion/bash_completion";
92 # This is a stripped down beets for testing of the external plugins.
93 externalTestArgs.beets = (lib.beets.override {
94 enableAlternatives = false;
95 enableCopyArtifacts = false;
96 enableExtraFiles = false;
97 }).overrideAttrs (lib.const {
98 doInstallCheck = false;
101 in pythonPackages.buildPythonApplication rec {
103 # While there is a stable version, 1.4.9, it is more than 1000 commits behind
104 # master and lacks many bug fixes and improvements[1]. Also important,
105 # unstable does not require bs1770gain[2].
106 # [1]: https://discourse.beets.io/t/forming-a-beets-core-team/639
107 # [2]: https://github.com/NixOS/nixpkgs/pull/90504
108 version = "unstable-2021-03-24";
110 src = fetchFromGitHub {
113 rev = "854b4ab48324afe8884fcd11fa47bd6258d2f4f7";
114 sha256 = "sha256-y5EWVNF4bd9fNvU6VkucMpenyFZuqdPkrqQDgG9ZPJY=";
117 propagatedBuildInputs = [
119 pythonPackages.enum34
120 pythonPackages.jellyfish
121 pythonPackages.munkres
122 pythonPackages.musicbrainzngs
123 pythonPackages.mutagen
124 pythonPackages.pyyaml
125 pythonPackages.unidecode
126 pythonPackages.gst-python
127 pythonPackages.pygobject3
128 pythonPackages.reflink
129 pythonPackages.confuse
130 pythonPackages.mediafile
131 gobject-introspection
132 ] ++ lib.optional enableAbsubmit essentia-extractor
133 ++ lib.optional enableAcoustid pythonPackages.pyacoustid
134 ++ lib.optional enableBeatport pythonPackages.requests_oauthlib
135 ++ lib.optional enableConvert ffmpeg
136 ++ lib.optional enableDiscogs pythonPackages.discogs_client
137 ++ lib.optional (enableFetchart
143 || enableSubsonicplaylist
144 || enableSubsonicupdate
145 || enableAcousticbrainz) pythonPackages.requests
146 ++ lib.optional enableKeyfinder keyfinder-cli
147 ++ lib.optional enableLastfm pythonPackages.pylast
148 ++ lib.optional enableLyrics pythonPackages.beautifulsoup4
149 ++ lib.optional enableMpd pythonPackages.mpd2
150 ++ lib.optional enableSonosUpdate pythonPackages.soco
151 ++ lib.optional enableThumbnails pythonPackages.pyxdg
152 ++ lib.optional (enableAura
153 || enableWeb) pythonPackages.flask
154 ++ lib.optional enableAlternatives beetsExternalPlugins.alternatives
155 ++ lib.optional enableCopyArtifacts beetsExternalPlugins.copyartifacts
156 ++ lib.optional enableExtraFiles beetsExternalPlugins.extrafiles
161 ] ++ (with gst_all_1; [
167 checkInputs = with pythonPackages; [
173 # Although considered as plugin dependencies, they are needed for the
174 # tests, for disabling them via an override makes the build fail. see:
175 # https://github.com/beetbox/beets/blob/v1.4.9/setup.py
183 # Bash completion fix for Nix
184 ./bash-completion-always-print.patch
185 # From some reason upstream assumes the program 'keyfinder-cli' is located
186 # in the path as `KeyFinder`
187 ./keyfinder-default-bin.patch
189 # We need to force ffmpeg as the default, since we do not package
190 # bs1770gain, and set the absolute path there, to avoid impurities.
191 ++ lib.optional enableReplaygain (substituteAll {
192 src = ./replaygain-default-ffmpeg.patch;
193 ffmpeg = lib.getBin ffmpeg;
195 # Put absolute Nix paths in place
196 ++ lib.optional enableConvert (substituteAll {
197 src = ./convert-plugin-ffmpeg-path.patch;
198 ffmpeg = lib.getBin ffmpeg;
200 ++ lib.optional enableBadfiles (substituteAll {
201 src = ./badfiles-plugin-nix-paths.patch;
206 # Disable failing tests
208 sed -i -e '/assertIn.*item.*path/d' test/test_info.py
209 echo echo completion tests passed > test/rsrc/test_completion.sh
211 sed -i -e 's/len(mf.images)/0/' test/test_zero.py
213 # Google Play Music was discontinued
214 rm -r beetsplug/gmusic.py
218 mkdir -p $out/share/zsh/site-functions
219 cp extra/_beet $out/share/zsh/site-functions/
225 find beetsplug -mindepth 1 \
226 \! -path 'beetsplug/__init__.py' -a \
227 \( -name '*.py' -o -path 'beetsplug/*/__init__.py' \) -print \
228 | sed -n -re 's|^beetsplug/([^/.]+).*|\1|p' \
229 | sort -u > plugins_available
231 ${diffPlugins allPlugins "plugins_available"}
238 LOCALE_ARCHIVE=${assert stdenv.isLinux; glibcLocales}/lib/locale/locale-archive \
239 BEETS_TEST_SHELL="${testShell}" \
240 BASH_COMPLETION_SCRIPT="${completion}" \
241 HOME="$(mktemp -d)" nosetests -v
246 doInstallCheck = true;
248 installCheckPhase = ''
249 runHook preInstallCheck
251 tmphome="$(mktemp -d)"
253 EDITOR="${writeScript "beetconfig.sh" ''
256 plugins: ${lib.concatStringsSep " " allEnabledPlugins}
258 ''}" HOME="$tmphome" "$out/bin/beet" config -e
259 EDITOR=true HOME="$tmphome" "$out/bin/beet" config -e
261 runHook postInstallCheck
264 makeWrapperArgs = [ "--set GI_TYPELIB_PATH \"$GI_TYPELIB_PATH\"" "--set GST_PLUGIN_SYSTEM_PATH_1_0 \"$GST_PLUGIN_SYSTEM_PATH_1_0\"" ];
267 # FIXME: remove in favor of pkgs.beetsExternalPlugins
268 externalPlugins = beetsExternalPlugins;
269 updateScript = unstableGitUpdater { url = "https://github.com/beetbox/beets"; };
273 description = "Music tagger and library organizer";
274 homepage = "http://beets.io";
275 license = licenses.mit;
276 maintainers = with maintainers; [ aszlig doronbehar lovesegfault pjones ];
277 platforms = platforms.linux;