From 8b86760e771471c92f88d0a1464c55f45f26664c Mon Sep 17 00:00:00 2001 From: Doron Behar Date: Mon, 5 Jan 2026 10:43:16 +0200 Subject: [PATCH 1/4] python3.pkgs.beets: use fixed-point arguments --- .../python-modules/beets/default.nix | 77 ++++++++++--------- 1 file changed, 39 insertions(+), 38 deletions(-) diff --git a/pkgs/development/python-modules/beets/default.nix b/pkgs/development/python-modules/beets/default.nix index a390d64fe7f6..207d4c9cac9a 100644 --- a/pkgs/development/python-modules/beets/default.nix +++ b/pkgs/development/python-modules/beets/default.nix @@ -25,7 +25,6 @@ stdenv, buildPythonPackage, fetchFromGitHub, - beets, # build-system poetry-core, @@ -106,22 +105,13 @@ runCommand, }: -let - # Avoid using `rec`, so that using e.g `passthru` or any other attributes - # defined inside, will have to be done via the beets argument, which can be - # overriden. Until `finalAttrs` support reaches `buildPythonPackage`, there - # is no way to avoid this. See: - # - # https://github.com/NixOS/nixpkgs/issues/258246 - version = "2.5.1"; -in -buildPythonPackage { +buildPythonPackage (finalAttrs: { pname = "beets"; version = "2.5.1"; src = fetchFromGitHub { owner = "beetbox"; repo = "beets"; - tag = "v${version}"; + tag = "v${finalAttrs.version}"; hash = "sha256-H3jcEHyK13+RHVlV4zp+8M3LZ0Jc2FdmAbLpekGozLA="; }; pyproject = true; @@ -154,7 +144,9 @@ buildPythonPackage { typing-extensions lap ] - ++ (lib.concatMap (p: p.propagatedBuildInputs) (lib.attrValues beets.passthru.plugins.enabled)); + ++ (lib.concatMap (p: p.propagatedBuildInputs) ( + lib.attrValues finalAttrs.finalPackage.passthru.plugins.enabled + )); nativeBuildInputs = [ gobject-introspection @@ -195,7 +187,7 @@ buildPythonPackage { 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 beets.passthru.plugins.wrapperBins}" + "--prefix PATH : ${lib.makeBinPath finalAttrs.finalPackage.passthru.plugins.wrapperBins}" ]; nativeCheckInputs = [ @@ -208,12 +200,12 @@ buildPythonPackage { pillow writableTmpDirAsHomeHook ] - ++ beets.passthru.plugins.wrapperBins; + ++ finalAttrs.finalPackage.passthru.plugins.wrapperBins; __darwinAllowLocalNetworking = true; disabledTestPaths = - beets.passthru.plugins.disabledTestPaths + finalAttrs.finalPackage.passthru.plugins.disabledTestPaths ++ [ # touches network "test/plugins/test_aura.py" @@ -255,14 +247,14 @@ buildPythonPackage { \( -name '*.py' -o -path 'beetsplug/*/__init__.py' \) -print \ | sed -n -re 's|^beetsplug/([^/.]+).*|\1|p' \ | sort -u > plugins_available - ${diffPlugins (lib.attrNames beets.passthru.plugins.builtins) "plugins_available"} + ${diffPlugins (lib.attrNames finalAttrs.finalPackage.passthru.plugins.builtins) "plugins_available"} export BEETS_TEST_SHELL="${lib.getExe bashInteractive} --norc" env EDITOR="${writeScript "beetconfig.sh" '' #!${runtimeShell} cat > "$1" < /dev/null + ${finalAttrs.finalPackage}/bin/beet -c $out/config.yaml > /dev/null ''; }; }; @@ -501,4 +502,4 @@ buildPythonPackage { platforms = lib.platforms.linux ++ lib.platforms.darwin; mainProgram = "beet"; }; -} +}) From 6e5237a8e774f158c07b7e403f1bc633cb3d3bd9 Mon Sep 17 00:00:00 2001 From: Doron Behar Date: Mon, 5 Jan 2026 10:59:47 +0200 Subject: [PATCH 2/4] python3.pkgs.beets: add a passthru.test adding a builtin plugin --- pkgs/development/python-modules/beets/default.nix | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/pkgs/development/python-modules/beets/default.nix b/pkgs/development/python-modules/beets/default.nix index 207d4c9cac9a..ac0f2718be3f 100644 --- a/pkgs/development/python-modules/beets/default.nix +++ b/pkgs/development/python-modules/beets/default.nix @@ -19,6 +19,9 @@ ** }; ** }; ** } + ** + ** For an example adding a builtin plugin, see + ** passthru.tests.with-new-builtin-plugin below */ { lib, @@ -486,6 +489,17 @@ buildPythonPackage (finalAttrs: { ${finalAttrs.finalPackage}/bin/beet -c $out/config.yaml > /dev/null ''; + with-new-builtin-plugin = finalAttrs.finalPackage.overrideAttrs ( + newAttrs: oldAttrs: { + postPatch = (oldAttrs.postPatch or "") + '' + mkdir -p beetsplug/my_special_plugin + touch beetsplug/my_special_plugin/__init__.py + ''; + passthru = lib.recursiveUpdate oldAttrs.passthru { + plugins.builtins.my_special_plugin = { }; + }; + } + ); }; }; From f9bdd4fed490fa85cdc3f7918f14a7addd779ba2 Mon Sep 17 00:00:00 2001 From: Doron Behar Date: Mon, 5 Jan 2026 11:28:42 +0200 Subject: [PATCH 3/4] beets-audible: use beets-minimal Previously, the attribute set: python3.pkgs.beets-minimal.passthru.plugins.enabled filtered out the disabled plugins from: python3.pkgs.beets.passthru.plugins.all , and not from: python3.pkgs.beets-minimal.passthru.plugins.all . This meant that before the commit titled: python3.pkgs.beets: use fixed-point arguments , the derivations `beets` and `beets-minimal` were the same. Now this change has significance, were as in out of context PR #477088 it didn't. --- pkgs/development/python-modules/beets-audible/default.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/development/python-modules/beets-audible/default.nix b/pkgs/development/python-modules/beets-audible/default.nix index 92bebc0c3142..42ec73c8f274 100644 --- a/pkgs/development/python-modules/beets-audible/default.nix +++ b/pkgs/development/python-modules/beets-audible/default.nix @@ -7,7 +7,7 @@ hatchling, # native - beets, + beets-minimal, # dependencies markdownify, @@ -35,7 +35,7 @@ buildPythonPackage rec { ]; nativeBuildInputs = [ - beets + beets-minimal ]; pythonRelaxDeps = true; From a615e9dcab270852e0e31fe92e91e714a887d171 Mon Sep 17 00:00:00 2001 From: Doron Behar Date: Sun, 18 Jan 2026 13:32:03 +0200 Subject: [PATCH 4/4] beets: test disabling plugins --- .../python-modules/beets/default.nix | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/pkgs/development/python-modules/beets/default.nix b/pkgs/development/python-modules/beets/default.nix index ac0f2718be3f..4fe0608dc154 100644 --- a/pkgs/development/python-modules/beets/default.nix +++ b/pkgs/development/python-modules/beets/default.nix @@ -106,6 +106,7 @@ # passthru.tests runCommand, + beets, }: buildPythonPackage (finalAttrs: { @@ -500,6 +501,32 @@ buildPythonPackage (finalAttrs: { }; } ); + # Test that disabling + with-mpd-plugins-disabled = beets.override { + pluginOverrides = { + # These two plugins require mpd2 Python dependency. If they are + # disabled, this dependency shouldn't be pulled, and the `runCommand` + # test below should fail with a `ModuleNotFoundError` + mpdstats.enable = false; + mpdupdate.enable = false; + }; + }; + mpd-plugins-really-disabled = runCommand "beets-mpd-plugins-disabled-test" { } '' + set -euo pipefail + export HOME=$(mktemp -d) + mkdir $out + + cat << EOF > $out/config.yaml + plugins: + - mpdstats + EOF + ${finalAttrs.finalPackage.passthru.tests.with-mpd-plugins-disabled}/bin/beet \ + -c $out/config.yaml \ + --help 2> $out/help-stderr || true + ${finalAttrs.finalPackage.passthru.tests.with-mpd-plugins-disabled}/bin/beet \ + -c $out/config.yaml \ + mpdstats --help 2> $out/mpdstats-help-stderr || true + ''; }; };