-
-
Notifications
You must be signed in to change notification settings - Fork 12.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
buildGoModule: Fix overriding with overlay-style stdenv #225051
base: staging
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It may not be a breaking change but I think we're to close to branch off for this so I'm a very strongly against including it in 23.05.
Also, I am planning to make a few changes to buildGoModule
after the branch, e.g. drop vendorSha256
and only have vendorHash
, it'll be easier and make this PR simpler if that happens first.
cc @NixOS/golang
Agree. Should I drop change to the the release note? I place them there just because the new release note hasn't come out yet. |
Would it be okay to just remove those |
Fine to leave them there for now, can be moved once the new release note is created after branch off.
Maybe, have to give it some thought first. Also, I'd appreciate it if you would revert all of the unrelated formatting changes, it makes the diff much harder to review. |
eeb5844
to
0e87a61
Compare
It turns out that the indentation difference is not just caused by Even then, I managed to make them align by making reasonable adjustment to the original expression (mainly by simplifying the The last commit contains the actual change. The relation between the original implementation and the new implementation can be seen from the diff. The expected attributes are organized at the beginning of the expression, and the corresponding comment documentation are prefixed with |
0e87a61
to
bd74d74
Compare
@ShamrockLee I'm switching this back to draft as it isn't going to be merged until after branch off. |
Still needs more testing but I've opened a PR to (mostly) get rid of vendorSha256. |
Go packages built with this buildGoModule implementation seems to take noticable longer to evaluate. Not sure if it also happens to #171586. How can we benchmark the evaluation time? |
bd74d74
to
fee7aae
Compare
c38e6a2
to
1bbeaed
Compare
(Just to add some documentation and correct the commit message. Sorry for another force-push.) |
1bbeaed
to
8ff7797
Compare
Facing the errors below when trying to build
It is probably caused by the
The buildPhase implementationbuildPhase = previousAttrs.buildPhase or ('' runHook preBuild |
It turns out that the dummy value of It doesn't cause problem in the original implementation because it is never passed as an argument to |
8ff7797
to
ed9af33
Compare
Change "platform dependant" to "platform-dependent" The word "dependant" (with suffix -ant) is used as a noun in British English, while the adjetive is "dependent" (-ent). Both are "dependent" in American English. Reference: https://www.merriam-webster.com/words-at-play/spelling-variants-dependent-vs-dependant https://dictionary.cambridge.org/dictionary/english/dependant
ed9af33
to
71e84bd
Compare
Unify how ldflags and tags are passed into buildGoModule Tested the build of package podman-tui, which passes in multiple tags.
ac320ae
to
3ef7d2a
Compare
I found a way to preserve the input arguments. This should make reviewing easier. I manually outdent the input argument set to make the diff cleaner, and then format it back in the following commit. |
Refactor `buildGoModule` to adopt the overlay-style `stdenv.mkDerivation` and to fix overriding. `vendorHash` can now be overridden directly using `overrideAttrs`. The `go-modules`, `vendorHash` and `vendorSha256` attributes are moved out of `passthru` as they now already exposed as attributes of `stdenv.mkDerivation`. The builder now only adds `go` to `passthru`. Outdent the input parameter attrset manually to ease reviewing
3ef7d2a
to
80d4d39
Compare
(Sorry for pressing the wrong button). |
I've moved |
What's the status of this? Could this be rebased? |
My understanding is that this PR as it is currently is superseded by a generic implementation in #234651 and that once that PR is merged this PR will be changed to use the generic implementation. |
Description of changes
The Go package builder
buildGoModule
is refactored to adopt the overlay-stylestdenv.mkDerivation
(#119942) and to fix overriding.vendorHash
can now be overridden directly usingoverrideAttrs
.Attribute overriding can now be done with simple
overrideAttrs
. TheoverrideModAttrs
andmod*Phase
attributes are kept as syntax sugar only. This implementation is already a drop-in replacement to the originalbuildGoModule
. (Addressing #86349 (comment))The
go-modules
,vendorHash
andvendorSha256
attributes are moved out ofpassthru
as they now already exposed as attributes ofstdenv.mkDerivation
. They can still be accessed as, say,pet.vendorHash
, but no longerpet.passthru.vendorHash
. The builder now only addsgo
topassthru
.Fixes #86349
Comparison to #171586:
#171586 makes use of the overlay-style
stdenv
to fix thevendorHash
overriding, but the builder (buildGoModule
) still accept attribute set only insted of a fixed-point function.This PR enables support to fixed-point function input. That is, one can write
Things done
sandbox = true
set innix.conf
? (See Nix manual)nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD"
. Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/
)