Skip to content

treewide: use overlays to pass a custom stdenv to buildPythonPackage / bulidPythonApplication#476401

Merged
MattSturgeon merged 15 commits intoNixOS:masterfrom
leona-ya:push-ttpknlqpqyqq
Jan 5, 2026
Merged

treewide: use overlays to pass a custom stdenv to buildPythonPackage / bulidPythonApplication#476401
MattSturgeon merged 15 commits intoNixOS:masterfrom
leona-ya:push-ttpknlqpqyqq

Conversation

@leona-ya
Copy link
Member

@leona-ya leona-ya commented Jan 2, 2026

Bumping oldestSupportedRelease to 2511 failed because of multiple

evaluation warning: Passing `stdenv` directly to `buildPythonPackage` or `buildPythonApplication` is deprecated. You should use their `.override` function instead, e.g:
    buildPythonPackage.override { stdenv = customStdenv; } { }

This PR either uses this approach or just removes superfluous stdenv declarations.

Required for #476384

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.

@leona-ya leona-ya marked this pull request as draft January 2, 2026 22:45
@leona-ya leona-ya force-pushed the push-ttpknlqpqyqq branch 2 times, most recently from 59d97f6 to 6f3fa6b Compare January 2, 2026 23:21
@leona-ya
Copy link
Member Author

leona-ya commented Jan 2, 2026

If anyone has a better idea than to drop the overriding tests, I'm happy for that.

@leona-ya leona-ya marked this pull request as ready for review January 2, 2026 23:25
@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. 10.rebuild-linux: 1 This PR causes 1 package to rebuild on Linux. 6.topic: python Python is a high-level, general-purpose programming language. labels Jan 2, 2026
@leona-ya
Copy link
Member Author

leona-ya commented Jan 2, 2026

I evaled nixpkgs locally with

diff --git a/pkgs/development/interpreters/python/python-packages-base.nix b/pkgs/development/interpreters/python/python-packages-base.nix
index c513561ce6..94b7bc126b 100644
--- a/pkgs/development/interpreters/python/python-packages-base.nix
+++ b/pkgs/development/interpreters/python/python-packages-base.nix
@@ -51,7 +51,7 @@
         args:
         if !(lib.isFunction args) && (args ? stdenv) then
           lib.warnIf (lib.oldestSupportedReleaseIsAtLeast 2511) ''
-            Passing `stdenv` directly to `buildPythonPackage` or `buildPythonApplication` is deprecated. You should use their `.override` function instead, e.g:
+            ${args.pname}: Passing `stdenv` directly to `buildPythonPackage` or `buildPythonApplication` is deprecated. You should use their `.override` function instead, e.g:
               buildPythonPackage.override { stdenv = customStdenv; } { }
           '' (f'.override { inherit (args) stdenv; } (removeAttrs args [ "stdenv" ]))
         else

you may want to do something similar. Otherwise it's almost impossible to find the failures.

@ShamrockLee
Copy link
Contributor

ShamrockLee commented Jan 3, 2026

I had thought it would only be triggered after Nixpkgs 26.05 branch-off. Sorry for causing the trouble.

@ShamrockLee
Copy link
Contributor

ShamrockLee commented Jan 3, 2026

If anyone has a better idea than to drop the overriding tests, I'm happy for that.

The test is meant to be removed aftre tree-wide migration.

@nixpkgs-ci nixpkgs-ci bot added the 10.rebuild-darwin: 1 This PR causes 1 package to rebuild on Darwin. label Jan 3, 2026
@ShamrockLee
Copy link
Contributor

Let's merge after updating the webmacs commit message.

Thank you for fixing them!

Passing `stdenv` directly to `buildPythonPackage` or `buildPythonApplication`
is deprecated with `oldestSupportedRelease = 2511`.
Copy link
Contributor

@MattSturgeon MattSturgeon left a comment

Choose a reason for hiding this comment

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

I had thought it would only be triggered after Nixpkgs 26.05 branch-off.

The "oldest supported release" gets bumped when the previous oldest supported release goes from "deprecated" to "unmaintained". It's not directly linked to branch-off; it usually happens a month or two after branch-off, IIUC.

I.e., 25.11 becomes the "oldest supported" at some point during the 26.05 cycle.

Sorry for causing the trouble.

We would've had to deal with this eventually, so no need to be sorry.

Thanks @leona-ya for handling it!

I evaled nixpkgs locally with [...] you may want to do something similar. Otherwise it's almost impossible to find the failures.

Good idea. It'd need to allow for pname being missing, but I agree it makes the error much more useful.

Comment on lines -449 to -462
overridePythonAttrs-stdenv-deprecated = {
expr =
(package-stub.overridePythonAttrs (_: {
stdenv = pkgs.clangStdenv;
})).stdenv;
expected = pkgs.clangStdenv;
};
overridePythonAttrs-override-clangStdenv-deprecated-nested = {
expr =
(package-stub-gcc.overridePythonAttrs {
stdenv = pkgs.clangStdenv;
}).stdenv;
expected = pkgs.clangStdenv;
};
Copy link
Contributor

@MattSturgeon MattSturgeon Jan 4, 2026

Choose a reason for hiding this comment

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

Ideally, I'd like to have a test that asserts the override still works and asserts the warning is printed. I don't think that's possible with the current overriding.nix.

I think we'd need to come up with something that evaluates test cases within a test derivation (similar to CI's eval or lib's lib/tests/test-with-nix.nix and ), that way we can capture the eval's stderr and make assertions on its content.

This is too complex to be in scope for this PR, and maybe too complex to be worth it for these two test cases. But maybe it'd be useful to have a way to implement more complex pkgs tests, like we already have for lib tests?

Copy link
Member Author

Choose a reason for hiding this comment

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

I also don't really know a way how this would be done easily. Also yes, probably out of scope here.

Copy link
Contributor

Choose a reason for hiding this comment

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

Agreed. If #477208 or another PR has a solution, it can revert this commit or introduce a new equivalent test. I don't want to block this PR by waiting for a solution.

@nixpkgs-ci nixpkgs-ci bot added the 12.approvals: 1 This PR was reviewed and approved by one person. label Jan 4, 2026
Passing `stdenv` directly to `buildPythonPackage` or `buildPythonApplication`
is deprecated with `oldestSupportedRelease = 2511`.
…th an override

Passing `stdenv` directly to `buildPythonPackage` or `buildPythonApplication`
is deprecated with `oldestSupportedRelease = 2511`.
…PythonApplication

Passing `stdenv` directly to `buildPythonPackage` or `buildPythonApplication`
is deprecated with `oldestSupportedRelease = 2511`.
Passing the normal `stdenv` to `buildPythonApplication` doensn't do anything.
…ythonApplication

Passing `stdenv` directly to `buildPythonPackage` or `buildPythonApplication`
is deprecated with `oldestSupportedRelease = 2511`.
Passing the normal `stdenv` to `buildPythonApplication` doensn't do anything.
… buildPythonApplication

Passing `stdenv` directly to `buildPythonPackage` or `buildPythonApplication`
is deprecated with `oldestSupportedRelease = 2511`.
Passing `python.stdenv` to `buildPythonApplication` doensn't do anything
…ion with an override

Passing `stdenv` directly to `buildPythonPackage` or `buildPythonApplication`
is deprecated with `oldestSupportedRelease = 2511`.
@leona-ya leona-ya force-pushed the push-ttpknlqpqyqq branch 2 times, most recently from f23c65d to f53ddbe Compare January 5, 2026 14:44
…tion with an override

Passing `stdenv` directly to `buildPythonPackage` or `buildPythonApplication`
is deprecated with `oldestSupportedRelease = 2511`.
…on with an override

Passing `stdenv` directly to `buildPythonPackage` or `buildPythonApplication`
is deprecated with `oldestSupportedRelease = 2511`.
…th an override

Passing `stdenv` directly to `buildPythonPackage` or `buildPythonApplication`
is deprecated with `oldestSupportedRelease = 2511`.
…th an override

Passing `stdenv` directly to `buildPythonPackage` or `buildPythonApplication`
is deprecated with `oldestSupportedRelease = 2511`.
…plication with an override

Passing `stdenv` directly to `buildPythonPackage` or `buildPythonApplication`
is deprecated with `oldestSupportedRelease = 2511`.
…on with an override

Passing `stdenv` directly to `buildPythonPackage` or `buildPythonApplication`
is deprecated with `oldestSupportedRelease = 2511`.
…n with an override

Passing `stdenv` directly to `buildPythonPackage` or `buildPythonApplication`
is deprecated with `oldestSupportedRelease = 2511`.
These tests now throw a warning which is prohibited inside Nixpkgs:
  Passing `stdenv` directly to `buildPythonPackage` or `buildPythonApplication` is deprecated. You should use their `.override` function instead, e.g:
    buildPythonPackage.override { stdenv = customStdenv; } { }
Copy link
Contributor

@MattSturgeon MattSturgeon left a comment

Choose a reason for hiding this comment

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

The only "changed" package is the test and the diff LGTM. Let's merge to unblock #476384

Thanks!

@MattSturgeon MattSturgeon added this pull request to the merge queue Jan 5, 2026
Merged via the queue into NixOS:master with commit f52e77d Jan 5, 2026
28 checks passed
@ShamrockLee ShamrockLee added the backport release-25.11 Backport PR automatically label Jan 5, 2026
@nixpkgs-ci
Copy link
Contributor

nixpkgs-ci bot commented Jan 5, 2026

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. 8.has: port to stable This PR already has a backport to the stable release. 10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. 10.rebuild-darwin: 1 This PR causes 1 package to rebuild on Darwin. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. 10.rebuild-linux: 1 This PR causes 1 package to rebuild on Linux. 12.approvals: 1 This PR was reviewed and approved by one person. backport release-25.11 Backport PR automatically

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants