2022-05-09 01:25:23 +02:00
|
|
|
{ stdenv
|
2023-01-15 12:03:41 +01:00
|
|
|
, fetchpatch
|
2022-05-07 22:42:01 +02:00
|
|
|
, bashInteractive
|
|
|
|
, diffPlugins
|
|
|
|
, glibcLocales
|
|
|
|
, gobject-introspection
|
|
|
|
, gst_all_1
|
2022-05-09 01:25:23 +02:00
|
|
|
, lib
|
2022-05-07 22:42:01 +02:00
|
|
|
, python3Packages
|
2022-11-21 20:13:36 +01:00
|
|
|
, sphinxHook
|
2022-05-07 22:42:01 +02:00
|
|
|
, runtimeShell
|
|
|
|
, writeScript
|
|
|
|
|
|
|
|
# plugin deps
|
2022-05-09 21:19:56 +02:00
|
|
|
, aacgain
|
|
|
|
, essentia-extractor
|
|
|
|
, ffmpeg
|
|
|
|
, flac
|
|
|
|
, imagemagick
|
|
|
|
, keyfinder-cli
|
|
|
|
, mp3gain
|
|
|
|
, mp3val
|
2022-05-07 22:42:01 +02:00
|
|
|
|
|
|
|
, src
|
|
|
|
, version
|
|
|
|
, pluginOverrides ? { }
|
|
|
|
, disableAllPlugins ? false
|
2022-08-03 23:51:43 +02:00
|
|
|
|
|
|
|
# tests
|
|
|
|
, runCommand
|
|
|
|
, beets
|
2022-05-07 22:42:01 +02:00
|
|
|
}@inputs:
|
|
|
|
let
|
|
|
|
inherit (lib) attrNames attrValues concatMap;
|
|
|
|
|
2022-06-01 01:00:02 +02:00
|
|
|
mkPlugin = { enable ? !disableAllPlugins, builtin ? false, propagatedBuildInputs ? [ ], testPaths ? [ ], wrapperBins ? [ ] }: {
|
|
|
|
inherit enable builtin propagatedBuildInputs testPaths wrapperBins;
|
2022-05-07 22:42:01 +02:00
|
|
|
};
|
|
|
|
|
2022-06-01 01:00:02 +02:00
|
|
|
basePlugins = lib.mapAttrs (_: a: { builtin = true; } // a) (import ./builtin-plugins.nix inputs);
|
|
|
|
allPlugins = lib.mapAttrs (_: mkPlugin) (lib.recursiveUpdate basePlugins pluginOverrides);
|
|
|
|
builtinPlugins = lib.filterAttrs (_: p: p.builtin) allPlugins;
|
2022-05-07 22:42:01 +02:00
|
|
|
enabledPlugins = lib.filterAttrs (_: p: p.enable) allPlugins;
|
|
|
|
disabledPlugins = lib.filterAttrs (_: p: !p.enable) allPlugins;
|
|
|
|
|
|
|
|
pluginWrapperBins = concatMap (p: p.wrapperBins) (attrValues enabledPlugins);
|
|
|
|
in
|
|
|
|
python3Packages.buildPythonApplication rec {
|
|
|
|
pname = "beets";
|
|
|
|
inherit src version;
|
|
|
|
|
|
|
|
patches = [
|
|
|
|
# Bash completion fix for Nix
|
|
|
|
./patches/bash-completion-always-print.patch
|
2023-01-15 12:03:41 +01:00
|
|
|
(fetchpatch {
|
|
|
|
# Fix unidecode>=1.3.5 compat
|
|
|
|
url = "https://github.com/beetbox/beets/commit/5ae1e0f3c8d3a450cb39f7933aa49bb78c2bc0d9.patch";
|
|
|
|
hash = "sha256-gqkrE+U1j3tt1qPRJufTGS/GftaSw/gweXunO/mCVG8=";
|
|
|
|
})
|
2022-05-07 22:42:01 +02:00
|
|
|
];
|
|
|
|
|
|
|
|
propagatedBuildInputs = with python3Packages; [
|
|
|
|
confuse
|
|
|
|
gst-python
|
|
|
|
jellyfish
|
|
|
|
mediafile
|
|
|
|
munkres
|
|
|
|
musicbrainzngs
|
|
|
|
mutagen
|
|
|
|
pygobject3
|
|
|
|
pyyaml
|
|
|
|
reflink
|
|
|
|
unidecode
|
|
|
|
] ++ (concatMap (p: p.propagatedBuildInputs) (attrValues enabledPlugins));
|
|
|
|
|
2022-08-02 20:36:46 +02:00
|
|
|
nativeBuildInputs = [
|
|
|
|
gobject-introspection
|
2022-11-21 20:13:36 +01:00
|
|
|
sphinxHook
|
2022-08-02 20:36:46 +02:00
|
|
|
];
|
|
|
|
|
2022-05-07 22:42:01 +02:00
|
|
|
buildInputs = [
|
|
|
|
] ++ (with gst_all_1; [
|
|
|
|
gst-plugins-base
|
|
|
|
gst-plugins-good
|
|
|
|
gst-plugins-ugly
|
|
|
|
]);
|
|
|
|
|
2022-11-21 20:13:36 +01:00
|
|
|
outputs = [ "out" "doc" "man" ];
|
|
|
|
sphinxBuilders = [ "html" "man" ];
|
|
|
|
|
2022-05-07 22:42:01 +02:00
|
|
|
postInstall = ''
|
|
|
|
mkdir -p $out/share/zsh/site-functions
|
|
|
|
cp extra/_beet $out/share/zsh/site-functions/
|
|
|
|
'';
|
|
|
|
|
|
|
|
doInstallCheck = true;
|
|
|
|
|
|
|
|
installCheckPhase = ''
|
|
|
|
runHook preInstallCheck
|
|
|
|
|
|
|
|
tmphome="$(mktemp -d)"
|
|
|
|
|
|
|
|
EDITOR="${writeScript "beetconfig.sh" ''
|
|
|
|
#!${runtimeShell}
|
|
|
|
cat > "$1" <<CFG
|
|
|
|
plugins: ${lib.concatStringsSep " " (attrNames enabledPlugins)}
|
|
|
|
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\""
|
|
|
|
"--prefix PATH : ${lib.makeBinPath pluginWrapperBins}"
|
|
|
|
];
|
|
|
|
|
2023-01-21 13:00:00 +01:00
|
|
|
nativeCheckInputs = with python3Packages; [
|
2022-05-07 22:42:01 +02:00
|
|
|
pytest
|
|
|
|
mock
|
|
|
|
rarfile
|
|
|
|
responses
|
|
|
|
] ++ pluginWrapperBins;
|
|
|
|
|
|
|
|
disabledTestPaths = lib.flatten (attrValues (lib.mapAttrs (n: v: v.testPaths ++ [ "test/test_${n}.py" ]) disabledPlugins));
|
|
|
|
|
|
|
|
checkPhase = ''
|
|
|
|
runHook preCheck
|
|
|
|
|
|
|
|
# Check for undefined plugins
|
|
|
|
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
|
2022-06-01 01:00:02 +02:00
|
|
|
${diffPlugins (attrNames builtinPlugins) "plugins_available"}
|
2022-05-07 22:42:01 +02:00
|
|
|
|
|
|
|
export BEETS_TEST_SHELL="${bashInteractive}/bin/bash --norc"
|
|
|
|
export HOME="$(mktemp -d)"
|
|
|
|
|
|
|
|
args=" -m pytest -r fEs"
|
|
|
|
eval "disabledTestPaths=($disabledTestPaths)"
|
|
|
|
for path in ''${disabledTestPaths[@]}; do
|
|
|
|
if [ -e "$path" ]; then
|
2022-05-21 16:35:43 +02:00
|
|
|
args+=" --ignore $path"
|
2022-05-07 22:42:01 +02:00
|
|
|
else
|
|
|
|
echo "Skipping non-existent test path '$path'"
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
2022-05-09 01:22:52 +02:00
|
|
|
python $args
|
2022-05-07 22:42:01 +02:00
|
|
|
|
|
|
|
runHook postCheck
|
|
|
|
'';
|
|
|
|
|
2022-08-03 23:51:43 +02:00
|
|
|
|
2022-07-26 00:49:52 +02:00
|
|
|
passthru.plugins = allPlugins;
|
|
|
|
|
2022-08-03 23:51:43 +02:00
|
|
|
passthru.tests.gstreamer = runCommand "beets-gstreamer-test" {
|
|
|
|
meta.timeout = 60;
|
|
|
|
}
|
|
|
|
''
|
|
|
|
set -euo pipefail
|
|
|
|
export HOME=$(mktemp -d)
|
|
|
|
mkdir $out
|
|
|
|
|
|
|
|
cat << EOF > $out/config.yaml
|
|
|
|
replaygain:
|
|
|
|
backend: gstreamer
|
|
|
|
EOF
|
|
|
|
|
|
|
|
echo $out/config.yaml
|
|
|
|
${beets}/bin/beet -c $out/config.yaml > /dev/null
|
|
|
|
'';
|
|
|
|
|
2022-05-07 22:42:01 +02:00
|
|
|
meta = with lib; {
|
|
|
|
description = "Music tagger and library organizer";
|
|
|
|
homepage = "https://beets.io";
|
|
|
|
license = licenses.mit;
|
|
|
|
maintainers = with maintainers; [ aszlig doronbehar lovesegfault pjones ];
|
|
|
|
platforms = platforms.linux;
|
|
|
|
};
|
|
|
|
}
|