3
0
Fork 0
forked from mirrors/nixpkgs
nixpkgs/pkgs/tools/audio/beets/default.nix

280 lines
9 KiB
Nix
Raw Normal View History

{ stdenv, lib, fetchFromGitHub, writeScript, glibcLocales, diffPlugins, substituteAll
, pythonPackages, imagemagick, gobject-introspection, gst_all_1
, runtimeShell, unstableGitUpdater
# external plugins package set
, beetsExternalPlugins
beets: Run tests for external plugins In order to run the tests for the external plugins of beets, we need to have beets itself as a dependency. So in order to do that, we now pass beets without plugins and tests to the nativeBuildInputs of the plugins so that we can run them. As soon as the plugins are built they become part of the final beets, which also has tests enabled, so disabling the tests for beets derivation that is used for external plugin tests is a non-issue here because they're going to be executed anyway. Enabling tests for the alternatives plugin is pretty straightforward, but in order to run tests for the copyartifacts plugin, we need to bump the source code to the latest Git master. The reason for this is that the version that was in use until now required to have the beets source directory alongside of the copyartifacts source code, but we already have beets available as a normal dependency. Updating copyartifacts to latest master largely consists of unit test changes and a few Python 3 compatibility changes. However, one change has the biggest stat, which is sbarakat/beets-copyartifacts@1a0c281da0be7251f414397960a83d60dc3a1520. Fortunately, the last change is just moving the implementation to a newer API from upstream beets and by the looks of the implementation it seems to break support for moving files. However, reverting this commit also reveals that moving files was already broken before, so it wouldn't matter much whether we have this version bump or not. Tested with the following command: nix-build -E '(import ./. {}).beets.override { enableAlternatives = true; enableCopyArtifacts = true; }' Signed-off-by: aszlig <aszlig@redmoonstudios.org> Cc: @domenkozar, @pjones, @Profpatsch, @michalrus
2017-09-02 01:03:03 +01:00
, enableAbsubmit ? lib.elem stdenv.hostPlatform.system essentia-extractor.meta.platforms, essentia-extractor
, enableAcousticbrainz ? true
, enableAcoustid ? true
, enableAura ? true
, enableBadfiles ? true, flac, mp3val
, enableBeatport ? true
, enableBpsync ? true
, enableConvert ? true, ffmpeg
, enableDeezer ? true
, enableDiscogs ? true
, enableEmbyupdate ? true
, enableFetchart ? true
, enableKeyfinder ? true, keyfinder-cli
, enableKodiupdate ? true
, enableLastfm ? true
, enableLoadext ? true
2021-03-11 11:19:18 +00:00
, enableLyrics ? true
, enableMpd ? true
, enablePlaylist ? true
, enableReplaygain ? true
, enableSonosUpdate ? true
, enableSubsonicplaylist ? true
, enableSubsonicupdate ? true
, enableThumbnails ? true
, enableWeb ? true
# External plugins
, enableAlternatives ? false
, enableCopyArtifacts ? false
, enableExtraFiles ? false
, bashInteractive, bash-completion
}:
assert enableBpsync -> enableBeatport;
let
optionalPlugins = {
2019-11-18 05:13:12 +00:00
absubmit = enableAbsubmit;
acousticbrainz = enableAcousticbrainz;
aura = enableAura;
badfiles = enableBadfiles;
beatport = enableBeatport;
bpsync = enableBpsync;
chroma = enableAcoustid;
convert = enableConvert;
deezer = enableDeezer;
discogs = enableDiscogs;
embyupdate = enableEmbyupdate;
fetchart = enableFetchart;
keyfinder = enableKeyfinder;
2017-06-28 21:27:17 +01:00
kodiupdate = enableKodiupdate;
lastgenre = enableLastfm;
lastimport = enableLastfm;
2019-09-23 05:23:56 +01:00
loadext = enableLoadext;
2021-03-11 11:19:18 +00:00
lyrics = enableLyrics;
mpdstats = enableMpd;
mpdupdate = enableMpd;
2019-09-23 05:23:56 +01:00
playlist = enablePlaylist;
replaygain = enableReplaygain;
sonosupdate = enableSonosUpdate;
subsonicplaylist = enableSubsonicplaylist;
2019-09-23 05:23:56 +01:00
subsonicupdate = enableSubsonicupdate;
thumbnails = enableThumbnails;
web = enableWeb;
};
pluginsWithoutDeps = [
"bareasc" "bench" "bpd" "bpm" "bucket" "duplicates" "edit" "embedart"
"export" "filefilter" "fish" "freedesktop" "fromfilename" "ftintitle" "fuzzy"
2021-03-11 11:19:18 +00:00
"hook" "ihate" "importadded" "importfeeds" "info" "inline" "ipfs"
"mbcollection" "mbsubmit" "mbsync" "metasync" "missing" "parentwork" "permissions" "play"
2019-11-18 05:13:12 +00:00
"plexupdate" "random" "rewrite" "scrub" "smartplaylist" "spotify" "the"
"types" "unimported" "zero"
];
enabledOptionalPlugins = lib.attrNames (lib.filterAttrs (_: lib.id) optionalPlugins);
allPlugins = pluginsWithoutDeps ++ lib.attrNames optionalPlugins;
allEnabledPlugins = pluginsWithoutDeps ++ enabledOptionalPlugins;
testShell = "${bashInteractive}/bin/bash --norc";
completion = "${bash-completion}/share/bash-completion/bash_completion";
beets: Run tests for external plugins In order to run the tests for the external plugins of beets, we need to have beets itself as a dependency. So in order to do that, we now pass beets without plugins and tests to the nativeBuildInputs of the plugins so that we can run them. As soon as the plugins are built they become part of the final beets, which also has tests enabled, so disabling the tests for beets derivation that is used for external plugin tests is a non-issue here because they're going to be executed anyway. Enabling tests for the alternatives plugin is pretty straightforward, but in order to run tests for the copyartifacts plugin, we need to bump the source code to the latest Git master. The reason for this is that the version that was in use until now required to have the beets source directory alongside of the copyartifacts source code, but we already have beets available as a normal dependency. Updating copyartifacts to latest master largely consists of unit test changes and a few Python 3 compatibility changes. However, one change has the biggest stat, which is sbarakat/beets-copyartifacts@1a0c281da0be7251f414397960a83d60dc3a1520. Fortunately, the last change is just moving the implementation to a newer API from upstream beets and by the looks of the implementation it seems to break support for moving files. However, reverting this commit also reveals that moving files was already broken before, so it wouldn't matter much whether we have this version bump or not. Tested with the following command: nix-build -E '(import ./. {}).beets.override { enableAlternatives = true; enableCopyArtifacts = true; }' Signed-off-by: aszlig <aszlig@redmoonstudios.org> Cc: @domenkozar, @pjones, @Profpatsch, @michalrus
2017-09-02 01:03:03 +01:00
# This is a stripped down beets for testing of the external plugins.
externalTestArgs.beets = (lib.beets.override {
beets: Run tests for external plugins In order to run the tests for the external plugins of beets, we need to have beets itself as a dependency. So in order to do that, we now pass beets without plugins and tests to the nativeBuildInputs of the plugins so that we can run them. As soon as the plugins are built they become part of the final beets, which also has tests enabled, so disabling the tests for beets derivation that is used for external plugin tests is a non-issue here because they're going to be executed anyway. Enabling tests for the alternatives plugin is pretty straightforward, but in order to run tests for the copyartifacts plugin, we need to bump the source code to the latest Git master. The reason for this is that the version that was in use until now required to have the beets source directory alongside of the copyartifacts source code, but we already have beets available as a normal dependency. Updating copyartifacts to latest master largely consists of unit test changes and a few Python 3 compatibility changes. However, one change has the biggest stat, which is sbarakat/beets-copyartifacts@1a0c281da0be7251f414397960a83d60dc3a1520. Fortunately, the last change is just moving the implementation to a newer API from upstream beets and by the looks of the implementation it seems to break support for moving files. However, reverting this commit also reveals that moving files was already broken before, so it wouldn't matter much whether we have this version bump or not. Tested with the following command: nix-build -E '(import ./. {}).beets.override { enableAlternatives = true; enableCopyArtifacts = true; }' Signed-off-by: aszlig <aszlig@redmoonstudios.org> Cc: @domenkozar, @pjones, @Profpatsch, @michalrus
2017-09-02 01:03:03 +01:00
enableAlternatives = false;
enableCopyArtifacts = false;
2020-08-07 22:05:13 +01:00
enableExtraFiles = false;
}).overrideAttrs (lib.const {
beets: Run tests for external plugins In order to run the tests for the external plugins of beets, we need to have beets itself as a dependency. So in order to do that, we now pass beets without plugins and tests to the nativeBuildInputs of the plugins so that we can run them. As soon as the plugins are built they become part of the final beets, which also has tests enabled, so disabling the tests for beets derivation that is used for external plugin tests is a non-issue here because they're going to be executed anyway. Enabling tests for the alternatives plugin is pretty straightforward, but in order to run tests for the copyartifacts plugin, we need to bump the source code to the latest Git master. The reason for this is that the version that was in use until now required to have the beets source directory alongside of the copyartifacts source code, but we already have beets available as a normal dependency. Updating copyartifacts to latest master largely consists of unit test changes and a few Python 3 compatibility changes. However, one change has the biggest stat, which is sbarakat/beets-copyartifacts@1a0c281da0be7251f414397960a83d60dc3a1520. Fortunately, the last change is just moving the implementation to a newer API from upstream beets and by the looks of the implementation it seems to break support for moving files. However, reverting this commit also reveals that moving files was already broken before, so it wouldn't matter much whether we have this version bump or not. Tested with the following command: nix-build -E '(import ./. {}).beets.override { enableAlternatives = true; enableCopyArtifacts = true; }' Signed-off-by: aszlig <aszlig@redmoonstudios.org> Cc: @domenkozar, @pjones, @Profpatsch, @michalrus
2017-09-02 01:03:03 +01:00
doInstallCheck = false;
});
in pythonPackages.buildPythonApplication rec {
2018-07-24 17:17:24 +01:00
pname = "beets";
# While there is a stable version, 1.4.9, it is more than 1000 commits behind
# master and lacks many bug fixes and improvements[1]. Also important,
# unstable does not require bs1770gain[2].
# [1]: https://discourse.beets.io/t/forming-a-beets-core-team/639
# [2]: https://github.com/NixOS/nixpkgs/pull/90504
version = "unstable-2021-05-13";
src = fetchFromGitHub {
owner = "beetbox";
repo = "beets";
rev = "1faa41f8c558d3f4415e5e48cf4513d50b466d34";
sha256 = "sha256-P0bV7WNqCYe9+3lqnFmAoRlb2asdsBUjzRMc24RngpU=";
};
propagatedBuildInputs = [
pythonPackages.six
pythonPackages.enum34
pythonPackages.jellyfish
pythonPackages.munkres
pythonPackages.musicbrainzngs
pythonPackages.mutagen
pythonPackages.pyyaml
pythonPackages.unidecode
pythonPackages.gst-python
pythonPackages.pygobject3
pythonPackages.reflink
pythonPackages.confuse
pythonPackages.mediafile
gobject-introspection
] ++ lib.optional enableAbsubmit essentia-extractor
++ lib.optional enableAcoustid pythonPackages.pyacoustid
++ lib.optional enableBeatport pythonPackages.requests_oauthlib
2021-03-11 11:19:18 +00:00
++ lib.optional enableConvert ffmpeg
++ lib.optional enableDiscogs pythonPackages.discogs_client
++ lib.optional (enableFetchart
|| enableDeezer
|| enableEmbyupdate
|| enableKodiupdate
|| enableLoadext
|| enablePlaylist
|| enableSubsonicplaylist
|| enableSubsonicupdate
|| enableAcousticbrainz) pythonPackages.requests
++ lib.optional enableKeyfinder keyfinder-cli
++ lib.optional enableLastfm pythonPackages.pylast
2021-03-11 11:19:18 +00:00
++ lib.optional enableLyrics pythonPackages.beautifulsoup4
++ lib.optional enableMpd pythonPackages.mpd2
++ lib.optional enableSonosUpdate pythonPackages.soco
++ lib.optional enableThumbnails pythonPackages.pyxdg
++ lib.optional (enableAura
|| enableWeb) pythonPackages.flask
++ lib.optional enableAlternatives beetsExternalPlugins.alternatives
++ lib.optional enableCopyArtifacts beetsExternalPlugins.copyartifacts
++ lib.optional enableExtraFiles beetsExternalPlugins.extrafiles
2020-08-07 22:05:13 +01:00
;
2019-02-20 19:07:21 +00:00
buildInputs = [
2015-06-01 04:51:04 +01:00
imagemagick
] ++ (with gst_all_1; [
gst-plugins-base
gst-plugins-good
gst-plugins-ugly
]);
2019-02-20 19:07:21 +00:00
checkInputs = with pythonPackages; [
beautifulsoup4
mock
nose
rarfile
responses
# Although considered as plugin dependencies, they are needed for the
# tests, for disabling them via an override makes the build fail. see:
# https://github.com/beetbox/beets/blob/v1.4.9/setup.py
pylast
mpd2
discogs_client
pyxdg
2019-02-20 19:07:21 +00:00
];
patches = [
# Bash completion fix for Nix
./bash-completion-always-print.patch
# From some reason upstream assumes the program 'keyfinder-cli' is located
# in the path as `KeyFinder`
./keyfinder-default-bin.patch
]
# We need to force ffmpeg as the default, since we do not package
# bs1770gain, and set the absolute path there, to avoid impurities.
++ lib.optional enableReplaygain (substituteAll {
src = ./replaygain-default-ffmpeg.patch;
ffmpeg = lib.getBin ffmpeg;
})
# Put absolute Nix paths in place
++ lib.optional enableConvert (substituteAll {
src = ./convert-plugin-ffmpeg-path.patch;
ffmpeg = lib.getBin ffmpeg;
})
++ lib.optional enableBadfiles (substituteAll {
src = ./badfiles-plugin-nix-paths.patch;
inherit mp3val flac;
})
;
# Disable failing tests
postPatch = ''
sed -i -e '/assertIn.*item.*path/d' test/test_info.py
echo echo completion tests passed > test/rsrc/test_completion.sh
sed -i -e 's/len(mf.images)/0/' test/test_zero.py
# Google Play Music was discontinued
rm -r beetsplug/gmusic.py
'';
2018-05-13 20:30:50 +01:00
postInstall = ''
mkdir -p $out/share/zsh/site-functions
cp extra/_beet $out/share/zsh/site-functions/
'';
doCheck = true;
preCheck = ''
find beetsplug -mindepth 1 \
\! -path 'beetsplug/__init__.py' -a \
\( -name '*.py' -o -path 'beetsplug/*/__init__.py' \) -print \
| sed -n -re 's|^beetsplug/([^/.]+).*|\1|p' \
| sort -u > plugins_available
${diffPlugins allPlugins "plugins_available"}
'';
checkPhase = ''
runHook preCheck
LANG=en_US.UTF-8 \
LOCALE_ARCHIVE=${assert stdenv.isLinux; glibcLocales}/lib/locale/locale-archive \
BEETS_TEST_SHELL="${testShell}" \
BASH_COMPLETION_SCRIPT="${completion}" \
2019-02-20 19:07:21 +00:00
HOME="$(mktemp -d)" nosetests -v
runHook postCheck
'';
doInstallCheck = true;
installCheckPhase = ''
runHook preInstallCheck
tmphome="$(mktemp -d)"
EDITOR="${writeScript "beetconfig.sh" ''
#!${runtimeShell}
cat > "$1" <<CFG
plugins: ${lib.concatStringsSep " " allEnabledPlugins}
CFG
''}" HOME="$tmphome" "$out/bin/beet" config -e
EDITOR=true HOME="$tmphome" "$out/bin/beet" config -e
runHook postInstallCheck
'';
makeWrapperArgs = [ "--set GI_TYPELIB_PATH \"$GI_TYPELIB_PATH\"" "--set GST_PLUGIN_SYSTEM_PATH_1_0 \"$GST_PLUGIN_SYSTEM_PATH_1_0\"" ];
passthru = {
# FIXME: remove in favor of pkgs.beetsExternalPlugins
externalPlugins = beetsExternalPlugins;
2021-02-01 02:27:37 +00:00
updateScript = unstableGitUpdater { url = "https://github.com/beetbox/beets"; };
};
meta = with lib; {
description = "Music tagger and library organizer";
2020-03-25 13:27:55 +00:00
homepage = "http://beets.io";
2015-06-01 04:51:04 +01:00
license = licenses.mit;
maintainers = with maintainers; [ aszlig doronbehar lovesegfault pjones ];
platforms = platforms.linux;
};
}