-
-
Notifications
You must be signed in to change notification settings - Fork 15.7k
buildGoModule: building Go binaries in two phases #57080
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
Merged
kalbasit
merged 13 commits into
NixOS:master
from
kalbasit:nixpkgs_create-build-go-module
Mar 14, 2019
Merged
buildGoModule: building Go binaries in two phases #57080
kalbasit
merged 13 commits into
NixOS:master
from
kalbasit:nixpkgs_create-build-go-module
Mar 14, 2019
Conversation
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
53d9cdf
to
53829fb
Compare
This comment has been minimized.
This comment has been minimized.
53829fb
to
1f21995
Compare
7fc305e
to
b3437e2
Compare
@GrahamcOfBorg build jx pet hugo gotools |
b3437e2
to
a1d010c
Compare
556fe3f
to
6f89cdd
Compare
@GrahamcOfBorg build jx pet hugo gotools |
45beb9d
to
174ba7e
Compare
48efa69
to
c717237
Compare
Mic92
reviewed
Mar 14, 2019
Mic92
reviewed
Mar 14, 2019
c717237
to
627b088
Compare
The function buildGoModule builds Go programs managed with Go modules. It builds a Go module through a two phase build: - An intermediate fetcher derivation. This derivation will be used to fetch all of the dependencies of the Go module. - A final derivation will use the output of the intermediate derivation to build the binaries and produce the final output.
af208c4
to
8f8e71c
Compare
@Mic92 I've addressed your comments. I have also conducted some tests to verify with certainty that the modules downloaded are not affected by changes to the upstream repository, such as with the release of a new verison. This PR is now clear to be merged as well. PTAL. |
Mic92
approved these changes
Mar 14, 2019
10 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
6.topic: golang
8.has: documentation
This PR adds or changes documentation
8.has: package (new)
This PR adds a new package
10.rebuild-darwin: 11-100
10.rebuild-linux: 11-100
11.by: package-maintainer
This PR was created by the maintainer of the package it changes
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.
Motivation for this change
This change provides a new builder called
buildGoModule
for building Go packages with go modules support in mind. It does build through two phases:go mod download
will be executed within the source directory to download all of the dependencies, and store them at$GOPATH/pkg/mod
. After removing the impure directory$GOPATH/pkg/mod/cache/vcs
, we persist$GOPATH/pkg/mod
as the $out of this derivation.GOPROXY
to point to the download directory within${go-modules}/cache/download
which instructs Go to skip any network call, and simply use the already-downloaded dependencies.The benefit of such infrastructure is that we no longer need tools such as dep2nix or vgo2nix to parse the go.mod and go.sum in order to generate Nix dependency file.
Things done
sandbox
innix.conf
on non-NixOS)nix-shell -p nox --run "nox-review wip"
./result/bin/
)nix path-info -S
before and after)hugo
.pet
.jx
.gotools
.terminal-parrot
.todoist
.hetzner-kube
.mod
.cc @ehmry @lethalman @fpletz @Mic92 @nlewo