@@ -1,4 +1,4 @@
1−{ stdenv, fetchFromGitHub, writeScript, glibcLocales, diffPlugins
1+{ stdenv, lib, fetchFromGitHub, writeScript, glibcLocales, diffPlugins, substituteAll
22, pythonPackages, imagemagick, gobject-introspection, gst_all_1
33, runtimeShell
44, fetchpatch
@@ -6,61 +6,70 @@
66# Attributes needed for tests of the external plugins
77, callPackage, beets
88
9−, enableAbsubmit ? stdenv.lib.elem stdenv.hostPlatform.system essentia-extractor.meta.platforms, essentia-extractor ? null
10−, enableAcousticbrainz ? true
11−, enableAcoustid ? true
12−, enableBadfiles ? true, flac ? null, mp3val ? null
13−, enableConvert ? true, ffmpeg_3 ? null
14−, enableDiscogs ? true
15−, enableEmbyupdate ? true
16−, enableFetchart ? true
17−, enableGmusic ? true
18−, enableKeyfinder ? true, keyfinder-cli ? null
19−, enableKodiupdate ? true
20−, enableLastfm ? true
21−, enableLoadext ? true
22−, enableMpd ? true
23−, enablePlaylist ? true
24−, enableReplaygain ? true, bs1770gain ? null
25−, enableSonosUpdate ? true
26−, enableSubsonicupdate ? true
27−, enableThumbnails ? true
28−, enableWeb ? true
9+, enableAbsubmit ? lib.elem stdenv.hostPlatform.system essentia-extractor.meta.platforms, essentia-extractor ? null
10+, enableAcousticbrainz ? true
11+, enableAcoustid ? true
12+, enableBadfiles ? true, flac ? null, mp3val ? null
13+, enableBeatport ? true
14+, enableBpsync ? true
15+, enableConvert ? true, ffmpeg ? null
16+, enableDeezer ? true
17+, enableDiscogs ? true
18+, enableEmbyupdate ? true
19+, enableFetchart ? true
20+, enableGmusic ? true
21+, enableKeyfinder ? true, keyfinder-cli ? null
22+, enableKodiupdate ? true
23+, enableLastfm ? true
24+, enableLoadext ? true
25+, enableMpd ? true
26+, enablePlaylist ? true
27+, enableReplaygain ? true
28+, enableSonosUpdate ? true
29+, enableSubsonicplaylist ? true
30+, enableSubsonicupdate ? true
31+, enableThumbnails ? true
32+, enableWeb ? true
2933
3034# External plugins
31−, enableAlternatives ? false
32−, enableCheck ? false, liboggz ? null
33−, enableCopyArtifacts ? false
34−, enableExtraFiles ? false
35+, enableAlternatives ? false
36+, enableCheck ? false, liboggz ? null
37+, enableCopyArtifacts ? false
38+, enableExtraFiles ? false
3539
3640, bashInteractive, bash-completion
3741}:
3842
39−assert enableAbsubmit -> essentia-extractor != null;
40−assert enableAcoustid -> pythonPackages.pyacoustid != null;
43+assert enableAbsubmit -> essentia-extractor != null;
44+assert enableAcoustid -> pythonPackages.pyacoustid != null;
4145assert enableBadfiles -> flac != null && mp3val != null;
46+assert enableBeatport -> pythonPackages.requests_oauthlib != null;
47+assert enableBpsync -> enableBeatport;
4248assert enableCheck -> flac != null && mp3val != null && liboggz != null;
43−assert enableConvert -> ffmpeg_3 != null;
44−assert enableDiscogs -> pythonPackages.discogs_client != null;
45−assert enableFetchart -> pythonPackages.responses != null;
46−assert enableGmusic -> pythonPackages.gmusicapi != null;
47−assert enableKeyfinder -> keyfinder-cli != null;
48−assert enableLastfm -> pythonPackages.pylast != null;
49−assert enableMpd -> pythonPackages.mpd2 != null;
50−assert enableReplaygain -> bs1770gain != null;
51−assert enableSonosUpdate -> pythonPackages.soco != null;
52−assert enableThumbnails -> pythonPackages.pyxdg != null;
53−assert enableWeb -> pythonPackages.flask != null;
54−
55−with stdenv.lib;
49+assert enableConvert -> ffmpeg != null;
50+assert enableDiscogs -> pythonPackages.discogs_client != null;
51+assert enableFetchart -> pythonPackages.responses != null;
52+assert enableGmusic -> pythonPackages.gmusicapi != null;
53+assert enableKeyfinder -> keyfinder-cli != null;
54+assert enableLastfm -> pythonPackages.pylast != null;
55+assert enableMpd -> pythonPackages.mpd2 != null;
56+assert enableReplaygain -> ffmpeg != null;
57+assert enableSonosUpdate -> pythonPackages.soco != null;
58+assert enableThumbnails -> pythonPackages.pyxdg != null;
59+assert enableWeb -> pythonPackages.flask != null;
60+
61+with lib;
5662
5763let
5864 optionalPlugins = {
5965 absubmit = enableAbsubmit;
6066 acousticbrainz = enableAcousticbrainz;
6167 badfiles = enableBadfiles;
68+ beatport = enableBeatport;
69+ bpsync = enableBpsync;
6270 chroma = enableAcoustid;
6371 convert = enableConvert;
72+ deezer = enableDeezer;
6473 discogs = enableDiscogs;
6574 embyupdate = enableEmbyupdate;
6675 fetchart = enableFetchart;
@@ -75,18 +84,19 @@ let
7584 playlist = enablePlaylist;
7685 replaygain = enableReplaygain;
7786 sonosupdate = enableSonosUpdate;
87+ subsonicplaylist = enableSubsonicplaylist;
7888 subsonicupdate = enableSubsonicupdate;
7989 thumbnails = enableThumbnails;
8090 web = enableWeb;
8191 };
8292
8393 pluginsWithoutDeps = [
84− "beatport" "bench" "bpd" "bpm" "bucket" "cue" "duplicates" "edit" "embedart"
85− "export" "filefilter" "freedesktop" "fromfilename" "ftintitle" "fuzzy"
94+ "bench" "bpd" "bpm" "bucket" "cue" "duplicates" "edit" "embedart"
95+ "export" "filefilter" "fish" "freedesktop" "fromfilename" "ftintitle" "fuzzy"
8696 "hook" "ihate" "importadded" "importfeeds" "info" "inline" "ipfs" "lyrics"
87− "mbcollection" "mbsubmit" "mbsync" "metasync" "missing" "permissions" "play"
97+ "mbcollection" "mbsubmit" "mbsync" "metasync" "missing" "parentwork" "permissions" "play"
8898 "plexupdate" "random" "rewrite" "scrub" "smartplaylist" "spotify" "the"
89− "types" "zero"
99+ "types" "unimported" "zero"
90100 ];
91101
92102 enabledOptionalPlugins = attrNames (filterAttrs (_: id) optionalPlugins);
@@ -102,28 +112,33 @@ let
102112 enableAlternatives = false;
103113 enableCopyArtifacts = false;
104114 enableExtraFiles = false;
105− }).overrideAttrs (stdenv.lib.const {
115+ }).overrideAttrs (const {
106116 doInstallCheck = false;
107117 });
108118
109119 pluginArgs = externalTestArgs // { inherit pythonPackages; };
110120
111121 plugins = {
112− alternatives = callPackage ./alternatives-plugin.nix pluginArgs;
113− check = callPackage ./check-plugin.nix pluginArgs;
114− copyartifacts = callPackage ./copyartifacts-plugin.nix pluginArgs;
115− extrafiles = callPackage ./extrafiles-plugin.nix pluginArgs;
122+ alternatives = callPackage ./plugins/alternatives.nix pluginArgs;
123+ check = callPackage ./plugins/check.nix pluginArgs;
124+ copyartifacts = callPackage ./plugins/copyartifacts.nix pluginArgs;
125+ extrafiles = callPackage ./plugins/extrafiles.nix pluginArgs;
116126 };
117127
118128in pythonPackages.buildPythonApplication rec {
119129 pname = "beets";
120− version = "1.4.9";
130+ # While there is a stable version, 1.4.9, it is more than 1000 commits behind
131+ # master and lacks many bug fixes and improvements[1]. Also important,
132+ # unstable does not require bs1770gain[2].
133+ # [1]: https://discourse.beets.io/t/forming-a-beets-core-team/639
134+ # [2]: https://github.com/NixOS/nixpkgs/pull/90504
135+ version = "unstable-2020-12-22";
121136
122137 src = fetchFromGitHub {
123138 owner = "beetbox";
124139 repo = "beets";
125− rev = "v${version}";
126− sha256 = "1qxdqbzvz97zgykzdwn78g2xyxmg0q2jdb12dnjnrwvhmjv67vi8";
140+ rev = "53dcb24d10788897f20c341774b474808ec2c0b6";
141+ sha256 = "sha256-P++NA13T2TRHW3Se10np8BSe/WRBYAKRte5xKoHKW50=";
127142 };
128143
129144 propagatedBuildInputs = [
@@ -137,19 +152,25 @@ in pythonPackages.buildPythonApplication rec {
137152 pythonPackages.unidecode
138153 pythonPackages.gst-python
139154 pythonPackages.pygobject3
155+ pythonPackages.reflink
156+ pythonPackages.confuse
157+ pythonPackages.mediafile
140158 gobject-introspection
141159 ] ++ optional enableAbsubmit essentia-extractor
142160 ++ optional enableAcoustid pythonPackages.pyacoustid
161+ ++ optional enableBeatport pythonPackages.requests_oauthlib
143162 ++ optional (enableFetchart
163+ || enableDeezer
144164 || enableEmbyupdate
145165 || enableKodiupdate
146166 || enableLoadext
147167 || enablePlaylist
168+ || enableSubsonicplaylist
148169 || enableSubsonicupdate
149170 || enableAcousticbrainz)
150171 pythonPackages.requests
151172 ++ optional enableCheck plugins.check
152− ++ optional enableConvert ffmpeg_3
173+ ++ optional enableConvert ffmpeg
153174 ++ optional enableDiscogs pythonPackages.discogs_client
154175 ++ optional enableGmusic pythonPackages.gmusicapi
155176 ++ optional enableKeyfinder keyfinder-cli
@@ -187,41 +208,35 @@ in pythonPackages.buildPythonApplication rec {
187208 ];
188209
189210 patches = [
190− ./replaygain-default-bs1770gain.patch
211+ # Bash completion fix for Nix
212+ ./bash-completion-always-print.patch
213+ # From some reason upstream assumes the program 'keyfinder-cli' is located
214+ # in the path as `KeyFinder`
191215 ./keyfinder-default-bin.patch
192− ./mutagen-1.43.patch
193− (fetchpatch {
194− # Fixes failing testcases around the werkzeug component; can dropped after 1.4.9
195− url = "https://github.com/beetbox/beets/commit/d43d54e21cde97f57f19486925ab56b419254cc8.patch";
196− sha256 = "13n2gzmcgfi0m2ycl2r1hpczgksplnkc3y6b66vg57rx5y8nnv5c";
216+ ]
217+ # We need to force ffmpeg as the default, since we do not package
218+ # bs1770gain, and set the absolute path there, to avoid impurities.
219+ ++ lib.optional enableReplaygain (substituteAll {
220+ src = ./replaygain-default-ffmpeg.patch;
221+ ffmpeg = getBin ffmpeg;
197222 })
223+ # Put absolute Nix paths in place
224+ ++ lib.optional enableConvert (substituteAll {
225+ src = ./convert-plugin-ffmpeg-path.patch;
226+ ffmpeg = getBin ffmpeg;
227+ })
228+ ++ lib.optional enableBadfiles (substituteAll {
229+ src = ./badfiles-plugin-nix-paths.patch;
230+ inherit mp3val flac;
231+ })
232+ ;
198233
199− # Fixes 548 tests due to breaking changes to the ast module
200− # https://github.com/beetbox/beets/pull/3621
201− # Can be dropped after 1.4.9
202− ./compatibility-with-breaking-changes-to-the-ast-module.patch
203− ];
204−
234+ # Disable failing tests
205235 postPatch = ''
206236 sed -i -e '/assertIn.*item.*path/d' test/test_info.py
207237 echo echo completion tests passed > test/rsrc/test_completion.sh
208238
209− sed -i -e '/^BASH_COMPLETION_PATHS *=/,/^])$/ {
210− /^])$/i u"${completion}"
211− }' beets/ui/commands.py
212− '' + optionalString enableBadfiles ''
213− sed -i -e '/self\.run_command(\[/ {
214− s,"flac","${flac.bin}/bin/flac",
215− s,"mp3val","${mp3val}/bin/mp3val",
216− }' beetsplug/badfiles.py
217− '' + optionalString enableConvert ''
218− sed -i -e 's,\(util\.command_output(\)\([^)]\+\)),\1[b"${ffmpeg_3.bin}/bin/ffmpeg" if args[0] == b"ffmpeg" else args[0]] + \2[1:]),' beetsplug/convert.py
219− '' + optionalString enableReplaygain ''
220− sed -i -re '
221− s!^( *cmd *= *b?['\'''"])(bs1770gain['\'''"])!\1${bs1770gain}/bin/\2!
222− ' beetsplug/replaygain.py
223− sed -i -e 's/if has_program.*bs1770gain.*:/if True:/' \
224− test/test_replaygain.py
239+ sed -i -e 's/len(mf.images)/0/' test/test_zero.py
225240 '';
226241
227242 postInstall = ''