tests.overriding: buildPythonPackage: test stdenv customisation via buildPythonPackage.override#455462
Merged
MattSturgeon merged 3 commits intoNixOS:masterfrom Dec 10, 2025
Merged
Conversation
stdenv customisation via buildPythonPackage.override
MattSturgeon
approved these changes
Oct 26, 2025
Contributor
MattSturgeon
left a comment
There was a problem hiding this comment.
Thanks for adding tests!
It'd be good if we also had tests covering the deprecated way of overriding stdenv (to avoid it breaking prematurely).
Now that you've added tests, are we ready to backport (minus release notes)?
Contributor
|
Although I've approved, I would ideally like to see these changes:
diff --git a/pkgs/test/overriding.nix b/pkgs/test/overriding.nix
index a5acddde3fef..0dc85634eae4 100644
--- a/pkgs/test/overriding.nix
+++ b/pkgs/test/overriding.nix
@@ -300,14 +300,18 @@ let
{
buildPythonPackage,
emptyDirectory,
+ extraAttrs,
}:
- buildPythonPackage {
- pname = "package-stub";
- version = "0.1.0";
- pyproject = true;
- src = emptyDirectory;
- }
- ) { };
+ buildPythonPackage (
+ {
+ pname = "package-stub";
+ version = "0.1.0";
+ pyproject = true;
+ src = emptyDirectory;
+ }
+ // extraAttrs
+ )
+ ) { extraAttrs = { }; };
package-stub-gcc = package-stub.override (previousArgs: {
buildPythonPackage = previousArgs.buildPythonPackage.override {
@@ -332,16 +336,36 @@ let
});
in
{
- buildPythonPackageOverrideStdenvGCC = {
- expr = package-stub-gcc.stdenv.cc.cc.pname == pkgs.gccStdenv.cc.cc.pname;
+ buildPythonPackage-override-gccStdenv = {
+ expr = package-stub-gcc.stdenv == pkgs.gccStdenv;
expected = true;
};
- buildPythonPackageOverrideStdenvClang = {
- expr = package-stub-clang.stdenv.cc.cc.pname == pkgs.clangStdenv.cc.cc.pname;
+ buildPythonPackage-override-clangStdenv = {
+ expr = package-stub-clang.stdenv == pkgs.clangStdenv;
expected = true;
};
- buildPythonPackageOverrideStdenvLibCXX = {
- expr = package-stub-libcxx.stdenv.cc.libcxx.pname == pkgs.libcxxStdenv.cc.libcxx.pname;
+ buildPythonPackage-override-libcxxStdenv = {
+ expr = package-stub-libcxx.stdenv == pkgs.libcxxStdenv;
+ expected = true;
+ };
+ buildPythonPackage-override-clangStdenv-deprecated = {
+ expr =
+ let
+ p = package-stub.override {
+ extraAttrs.stdenv = pkgs.clangStdenv;
+ };
+ in
+ p.stdenv == pkgs.clangStdenv;
+ expected = true;
+ };
+ overridePythonAttrs-override-clangStdenv-deprecated = {
+ expr =
+ let
+ p = package-stub.overridePythonAttrs {
+ stdenv = pkgs.clangStdenv;
+ };
+ in
+ p.stdenv == pkgs.clangStdenv;
expected = true;
};
I also tried adding this test case: overridePythonAttrs-override-clangStdenv-deprecated-nested = {
expr =
let
p = package-stub-gcc.overridePythonAttrs {
stdenv = pkgs.clangStdenv;
};
in
p.stdenv == pkgs.clangStdenv;
expected = true;
};However, it fails because of:
In a separate PR, we'll need to find a better way to handle that scenario. |
13 tasks
34f3742 to
c994993
Compare
Co-authored-by: Matt Sturgeon <matt@sturgeon.me.uk>
c994993 to
7ac8eda
Compare
Contributor
Author
Addressed. Thanks for your suggestions! |
Co-authored-by: Matt Sturgeon <matt@sturgeon.me.uk>
7ac8eda to
06711e4
Compare
MattSturgeon
approved these changes
Dec 10, 2025
This comment has been minimized.
This comment has been minimized.
Contributor
Author
Contributor
|
Successfully created backport PR for |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds overriding tests for PR #271762
stdenvcustomization through(buildPython*.override { inherit stdenv; })#271762Things done
passthru.tests.nixpkgs-reviewon this PR. See nixpkgs-review usage../result/bin/.Add a 👍 reaction to pull requests you find important.