Skip to content

python3.pkgs.beets: allow to override passthru#467091

Merged
doronbehar merged 2 commits intoNixOS:masterfrom
doronbehar:pkg/beets@overridePassthru
Dec 24, 2025
Merged

python3.pkgs.beets: allow to override passthru#467091
doronbehar merged 2 commits intoNixOS:masterfrom
doronbehar:pkg/beets@overridePassthru

Conversation

@doronbehar
Copy link
Contributor

@doronbehar doronbehar commented Dec 2, 2025

Tested with:

diff --git i/pkgs/top-level/python-packages.nix w/pkgs/top-level/python-packages.nix
index 6051daa09f6a..2dde3c3c327b 100644
--- i/pkgs/top-level/python-packages.nix
+++ w/pkgs/top-level/python-packages.nix
@@ -1871,6 +1871,25 @@ self: super: with self; {
   beets = callPackage ../development/python-modules/beets {
     inherit (pkgs) chromaprint;
   };
+  beets-test = let
+    # Not using `overridePythonAttrs` because it doesn't produce a derivation
+    # with a `.override` method, as required later.
+    patched = beets.overrideAttrs(oldAttrs: {
+      patches = oldAttrs.patches ++ [
+        (pkgs.fetchpatch {
+          name = "beets-importsource-plugin.patch";
+          url = "https://github.com/beetbox/beets/commit/9608ec0925979356fb7bf3a870fbde760362a973.patch";
+          hash = "sha256-wseJe+2jS7hsKKJ5jWrkBlPmOkVwLhPS23PRMqAR7is=";
+        })
+      ];
+      passthru = lib.recursiveUpdate oldAttrs.passthru {
+        plugins.builtins.importsource = {};
+      };
+    });
+  in
+    patched.override {
+      beets = patched;
+    };
 
   beets-alternatives = callPackage ../development/python-modules/beets-alternatives { };
 

Things done

  • Built on platform:
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • Tested, as applicable:
  • Ran nixpkgs-review on this PR. See nixpkgs-review usage.
  • Tested basic functionality of all binary files, usually in ./result/bin/.
  • Nixpkgs Release Notes
    • Package update: when the change is major or breaking.
  • NixOS Release Notes
    • Module addition: when adding a new NixOS module.
    • Module update: when the change is significant.
  • Fits CONTRIBUTING.md, pkgs/README.md, maintainers/README.md and other READMEs.

Add a 👍 reaction to pull requests you find important.

@nixpkgs-ci nixpkgs-ci bot added 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. 10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. 11.by: package-maintainer This PR was created by a maintainer of all the package it changes. 6.topic: python Python is a high-level, general-purpose programming language. labels Dec 2, 2025
@doronbehar doronbehar requested a review from aszlig December 2, 2025 11:50
@doronbehar doronbehar marked this pull request as ready for review December 2, 2025 11:50
Copy link
Member

@aszlig aszlig left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think being able to override all attributes is generally a good thing.

I'm not so sure whether we want people to override use passthru for defining new plugin options, since I'd consider that to be internal.

What's the actual thing that motivated you to address this?

@doronbehar
Copy link
Contributor Author

Thanks for the review :).

@doronbehar
Copy link
Contributor Author

I'm not so sure whether we want people to override use passthru for defining new plugin options, since I'd consider that to be internal.

What's the actual thing that motivated you to address this?

See the example diff in the top level comment.

Comment on lines 112 to 113
# overriden. Until `finalAttrs` support reaches `buildPythonPackage`, there
# is no way to avoid this.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# overriden. Until `finalAttrs` support reaches `buildPythonPackage`, there
# is no way to avoid this.
# overriden. Until `finalAttrs` support reaches `buildPythonPackage`, there
# is no way to avoid this.
#
# See: https://github.com/NixOS/nixpkgs/issues/258246

Nice to have a link to the relevant issue here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice to have a link to the relevant issue here.

I agree!

Copy link
Contributor

@9999years 9999years left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Kind of rough usage here; probably worth a comment or a passthru.tests attribute. Still nice to be able to do this.

@nixpkgs-ci nixpkgs-ci bot added the 12.approvals: 1 This PR was reviewed and approved by one person. label Dec 23, 2025
@doronbehar doronbehar force-pushed the pkg/beets@overridePassthru branch from a351fed to 23b24be Compare December 24, 2025 07:22
@doronbehar
Copy link
Contributor Author

Kind of rough usage here; probably worth a comment or a passthru.tests attribute. Still nice to be able to do this.

I agree, your PR will make this UX better :).

@doronbehar doronbehar enabled auto-merge December 24, 2025 07:24
@doronbehar doronbehar added this pull request to the merge queue Dec 24, 2025
Merged via the queue into NixOS:master with commit 2ec0cdf Dec 24, 2025
26 of 30 checks passed
@doronbehar doronbehar deleted the pkg/beets@overridePassthru branch December 24, 2025 07:33
doronbehar pushed a commit to 9999years/nixpkgs that referenced this pull request Dec 25, 2025
@trofi
Copy link
Contributor

trofi commented Dec 29, 2025

Bisect says that this caused infinite recursion eval failure (was python version failure before):

$ nix-instantiate -A pypy2Packages.beets
error:
       … while evaluating a branch condition
         at pkgs/development/interpreters/python/passthrufun.nix:43:13:
           42|             name: value:
           43|             if lib.isDerivation value then
             |             ^
           44|               lib.extendDerivation (

       … while calling a functor (an attribute set with a '__functor' attribute)
         at lib/customisation.nix:334:7:
          333|     if missingArgs == { } then
          334|       makeOverridable f allArgs
             |       ^
          335|     # This needs to be an abort so it can't be caught with `builtins.tryEval`,

       (stack trace truncated; use '--show-trace' to show the full, detailed trace)

       error: infinite recursion encountered
       at pkgs/development/python-modules/beets/default.nix:216:5:
          215|   disabledTestPaths =
          216|     beets.passthru.plugins.disabledTestPaths
             |     ^
          217|     ++ [

@doronbehar
Copy link
Contributor Author

Damn you are right. I'm sorry about that and I wish Python packages had a .overrideAttrs(final: prev: style overriding possible...

#258246

I'm open to implementing a workaround just for beets though.

@doronbehar
Copy link
Contributor Author

doronbehar commented Jan 5, 2026

Just for reference, now with #271387 merged 🎉, and with the changes here:

A much nicer override is possible, and is part of a new passthru.tests test there. Your review is welcome.

@doronbehar
Copy link
Contributor Author

doronbehar commented Jan 5, 2026

Oh and @trofi FYI it seems that #271387 hasn't helped instantiating pypyPackages.beets. On the branch of #477084 . See:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

6.topic: python Python is a high-level, general-purpose programming language. 10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. 11.by: package-maintainer This PR was created by a maintainer of all the package it changes. 12.approvals: 1 This PR was reviewed and approved by one person.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants