Skip to content

buildGoModule: warn for passthru.overrideModAttrs lost after overriding#434546

Merged
philiptaron merged 1 commit intoNixOS:masterfrom
ShamrockLee:build-go-module-passthru-warning
Aug 28, 2025
Merged

buildGoModule: warn for passthru.overrideModAttrs lost after overriding#434546
philiptaron merged 1 commit intoNixOS:masterfrom
ShamrockLee:build-go-module-passthru-warning

Conversation

@ShamrockLee
Copy link
Contributor

@ShamrockLee ShamrockLee commented Aug 17, 2025

This PR adds a warning to the workaround introduced in PR #339042, to remind users their dropping passthru attributes would result in the loss of buildGoModule's overridden overrideGoModule (added in PR #225051).

Errors shouldn't pass silently, and there will be more packages storing overriding information in passthru as more frameworks transit from custom overriders to <pkg>.overrideAttrs. Let's enforce this with a warning.

Things done

  • Built on platform: (no rebuild)
    • 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-go-module-passthru-warning branch from 90fe612 to 3d08960 Compare August 17, 2025 20:11
@nixpkgs-ci nixpkgs-ci bot added 2.status: merge conflict This PR has merge conflicts with the target branch 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. 8.has: changelog This PR adds or changes release notes 6.topic: golang Go is a high-level general purpose programming language that is statically typed and compiled. 8.has: documentation This PR adds or changes documentation and removed 2.status: merge conflict This PR has merge conflicts with the target branch labels Aug 17, 2025
@ShamrockLee ShamrockLee force-pushed the build-go-module-passthru-warning branch 2 times, most recently from a542f6e to b323044 Compare August 17, 2025 20:23
@ShamrockLee
Copy link
Contributor Author

nixpkgs-review result

Generated using nixpkgs-review.

Command: nixpkgs-review pr 434546
Commit: b3230442063e36c97dba762d0aef5ddabded9b34


x86_64-linux

⏩ 1 package blacklisted:
  • tests.nixos-functions.nixos-test
✅ 1 package built:
  • nixpkgs-manual

@ShamrockLee ShamrockLee marked this pull request as ready for review August 17, 2025 20:33
@philiptaron
Copy link
Contributor

Can you share a test case where I can see this error where I wouldn't have previously? Something I can test in nix repl.

@ShamrockLee
Copy link
Contributor Author

ShamrockLee commented Aug 28, 2025

Can you share a test case where I can see this error where I wouldn't have previously? Something I can test in nix repl.

Sandro demonstrated a reproducer by overriding with { passthru = { }; }. A worked reproducer:

{ pet }:
pet.overrideAttrs {
  passthru = { };
}

We could compare the the error handling after #225051 (attribute missing error), #339042 (falling back to the initial value silently), and this PR (falling back to the inintial value with a warning message) with the following commands:

# After PR #225051 "buildGoModule: Fix overriding with overlay-style stdenv"
nix eval --impure --expr "((
  builtins.getFlake ''github:NixOS/nixpkgs/0d920a91a29ec8668ecbf967b485136000ad5d94''
).outputs.legacyPackages.\${builtins.currentSystem}.pet.overrideAttrs {
  passthru = { };
}).outPath"

# After PR #339042 "buildGoModule: be nicer when overrideAttrs clears passthru"
nix eval --impure --expr "((
  builtins.getFlake ''github:NixOS/nixpkgs/0e21bc6af9b313944aaca5f6e8ccbbf4a9c978f7''
).outputs.legacyPackages.\${builtins.currentSystem}.pet.overrideAttrs {
  passthru = { };
}).outPath"

# After this change
nix eval --impure --expr "((
  builtins.getFlake ''github:NixOS/nixpkgs/refs/pull/434546/head''
).outputs.legacyPackages.\${builtins.currentSystem}.pet.overrideAttrs {
  passthru = { };
}).outPath"

@ShamrockLee ShamrockLee force-pushed the build-go-module-passthru-warning branch from b323044 to 8c54246 Compare August 28, 2025 19:11
@ShamrockLee
Copy link
Contributor Author

Warning message updated to include position information.

@philiptaron
Copy link
Contributor

passthru = [ ];

Assuming this is actually passthru = { }; -- the other one throws an eval error.

Copy link
Contributor

@philiptaron philiptaron left a comment

Choose a reason for hiding this comment

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

Yeah, OK.

@philiptaron philiptaron merged commit ad1cab4 into NixOS:master Aug 28, 2025
28 of 31 checks passed
@ShamrockLee ShamrockLee deleted the build-go-module-passthru-warning branch August 30, 2025 16:29
@acid-bong
Copy link
Contributor

acid-bong commented Nov 1, 2025

Hmm, I decided to make this passthru non-overridable in #457308 (by setting it on the right of //), I guess I'll need to revert this too?

@ShamrockLee
Copy link
Contributor Author

ShamrockLee commented Nov 2, 2025

Hmm, I decided to make this passthru non-overridable in #457308 (by setting it on the right of //), I guess I'll need to revert this too?

Nope.

  1. The change proposed in buildGoModule: intersect given and available meta.platforms #457308 does not prevent passthru from being overridden with <pkg>.overrideAttrs, and this PR (buildGoModule: warn for passthru.overrideModAttrs lost after overriding #434546) is to prevent passthru.overrideModAttrs from being removed from passthru after <pkg>.overrideAttrs overriding.

  2. Hacks to prevent <pkg>.overrideAttrs from changing passthru.overrideModAttrs is not what we want, as the existence of passthru.overrideModAttrs is mainly to allow goModule to be overridden while also allowing vendorHash to be overridden as null.

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

Labels

6.topic: golang Go is a high-level general purpose programming language that is statically typed and compiled. 8.has: changelog This PR adds or changes release notes 8.has: documentation This PR adds or changes documentation 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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants