Skip to content

buildPython*: extend overrideStdenvCompat to fixed-point arguments#477208

Merged
MattSturgeon merged 3 commits intoNixOS:masterfrom
ShamrockLee:build-python-stdenv-compat-extended
Jan 20, 2026
Merged

buildPython*: extend overrideStdenvCompat to fixed-point arguments#477208
MattSturgeon merged 3 commits intoNixOS:masterfrom
ShamrockLee:build-python-stdenv-compat-extended

Conversation

@ShamrockLee
Copy link
Contributor

@ShamrockLee ShamrockLee commented Jan 5, 2026

Description

Implementation

  • Expose the stdenv argument as passthru.__stdenvPythonCompat when specified.
  • Attach the warning message to passthru.__stdenvPythonCompat (instead of inside overrideStdenvCompat).
  • Inside overrideStdenvCompat in python-packages-base.nix, construct a Python package with overridden stdenv if <python pkg>.__stdenvPythonCompat exists.
  • Add argument handleMsgStdenvArg to <python pkg>.override to pass the message handling function (ignoreing, warning, throwing, etc.), with a comment about its being an implementation detail.
  • Make tests.overriding's overridePythonAttrs-stdenv-deprecated ignore the deprecation warning with handleMsgStdenvArg.

Effect

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.

@ShamrockLee ShamrockLee force-pushed the build-python-stdenv-compat-extended branch from 45313a0 to 2543891 Compare January 5, 2026 16:50
@nixpkgs-ci nixpkgs-ci bot added 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. 10.rebuild-linux: 0 This PR does not cause any packages to rebuild on Linux. 6.topic: python Python is a high-level, general-purpose programming language. labels Jan 5, 2026
@ShamrockLee ShamrockLee marked this pull request as ready for review January 5, 2026 17:11
@ShamrockLee ShamrockLee added the backport release-25.11 Backport PR automatically label Jan 5, 2026
@nixpkgs-ci nixpkgs-ci bot requested review from mweinelt and natsukium January 5, 2026 17:17
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 commented commit-by-commit, and the GitHub review summary seems very confused. Hopefully this posts everything ok... 🤞🏻

@nixpkgs-ci nixpkgs-ci bot added the 2.status: merge conflict This PR has merge conflicts with the target branch label Jan 5, 2026
@ShamrockLee ShamrockLee force-pushed the build-python-stdenv-compat-extended branch from 2543891 to c2d8b10 Compare January 5, 2026 20:33
@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-darwin: 1 This PR causes 1 package to rebuild on Darwin. 10.rebuild-linux: 1 This PR causes 1 package to rebuild on Linux. and removed 2.status: merge conflict This PR has merge conflicts with the target branch 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. 10.rebuild-linux: 0 This PR does not cause any packages to rebuild on Linux. labels Jan 5, 2026
@ShamrockLee ShamrockLee force-pushed the build-python-stdenv-compat-extended branch from c2d8b10 to a4a7c43 Compare January 5, 2026 20:44
@MattSturgeon MattSturgeon mentioned this pull request Jan 7, 2026
1 task
@ShamrockLee ShamrockLee force-pushed the build-python-stdenv-compat-extended branch from a4a7c43 to 31c9079 Compare January 9, 2026 03:40
@nixpkgs-ci nixpkgs-ci bot removed 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. labels Jan 9, 2026
@nixpkgs-ci nixpkgs-ci bot added 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. 10.rebuild-linux: 0 This PR does not cause any packages to rebuild on Linux. and removed 10.rebuild-darwin: 1 This PR causes 1 package to rebuild on Darwin. 10.rebuild-linux: 1 This PR causes 1 package to rebuild on Linux. labels Jan 9, 2026
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 tested this locally against #477760, and tests.eval built successfully. Admittedly, the test coverage for stdenv overrides isn't extensive, but it does provide a sanity check 😁

@ShamrockLee ShamrockLee force-pushed the build-python-stdenv-compat-extended branch 2 times, most recently from ea064b0 to 22453e0 Compare January 12, 2026 05:52
@ShamrockLee ShamrockLee force-pushed the build-python-stdenv-compat-extended branch 2 times, most recently from d635ffa to 9cc99be Compare January 15, 2026 06:15
@ShamrockLee ShamrockLee force-pushed the build-python-stdenv-compat-extended branch from 26bc9f8 to 7304784 Compare January 19, 2026 06:27
ShamrockLee and others added 3 commits January 19, 2026 14:29
… override value

If Nix supports lazy attribute names in the future,
this change will make `<python package>.override` warning-free
and make such warning (or future throw) remediateable
via another override.
with `passthru.__stdenvPythonCompat`

Co-authored-by: Matt Sturgeon <[email protected]>
@ShamrockLee ShamrockLee force-pushed the build-python-stdenv-compat-extended branch from 7304784 to de48b6a Compare January 19, 2026 06:29
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.

LGTM. Thanks! I think I'll merge this to avoid further delays.

Copy link
Contributor

Choose a reason for hiding this comment

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

The error message mentions buildPythonPackage and buildPythonApplication, but it also catches passing stdenv to overridePythonAttrs.

Ideally, we'd make this a smart warning that knows which function the user was using to incorrectly supply stdenv. I can't think of a sane way to handle that though.

I'm not suggesting we reword the warning to mention all three funtions, as that would quickly get rather verbose. I think this is out-of-scope for this PR anyway, as I think overrideStdenvCompat already handled overridePythonAttrs?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

How about adding position information?

Copy link
Contributor

Choose a reason for hiding this comment

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

Would this benefit from a comment explaining why we add __stdenvPythonCompat (i.e. for overrideStdenvCompat), mentioning that it is internal, reminding us to remove when dropping overrideStdenvCompat, etc?

@MattSturgeon MattSturgeon changed the title buildPython*: extend overrideStdenvCompat to fixed-point arguments and preserve its test after warning takes effect buildPython*: extend overrideStdenvCompat to fixed-point arguments Jan 20, 2026
@MattSturgeon MattSturgeon added this pull request to the merge queue Jan 20, 2026
@nixpkgs-ci nixpkgs-ci bot added the 12.approvals: 1 This PR was reviewed and approved by one person. label Jan 20, 2026
Merged via the queue into NixOS:master with commit e6959ad Jan 20, 2026
33 of 35 checks passed
@nixpkgs-ci
Copy link
Contributor

nixpkgs-ci bot commented Jan 20, 2026

Backport failed for release-25.11, because it was unable to cherry-pick the commit(s).

Please cherry-pick the changes locally and resolve any conflicts.

git fetch origin release-25.11
git worktree add -d .worktree/backport-477208-to-release-25.11 origin/release-25.11
cd .worktree/backport-477208-to-release-25.11
git switch --create backport-477208-to-release-25.11
git cherry-pick -x 4ef0c2ded41c446cd8cd2611554487363e28ee15 5b114f0534d820d60186d402e8964b64d67e810e de48b6a845e7f206d8c11075a507814b6b5d13c7

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: 0 This PR does not cause any packages to rebuild on Darwin. 10.rebuild-linux: 0 This PR does not cause any packages 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.

2 participants