diff --git a/doc/languages-frameworks/go.xml b/doc/languages-frameworks/go.xml index 7cff7a85c62c..ebdcf616054c 100644 --- a/doc/languages-frameworks/go.xml +++ b/doc/languages-frameworks/go.xml @@ -38,11 +38,7 @@ pet = buildGoModule rec { vendorSha256 = "1879j77k96684wi554rkjxydrj8g3hpp0kvxz03sd8dmwr3lh83j"; - subPackages = [ "." ]; - - deleteVendor = true; - - runVend = true; + runVend = true; meta = with lib; { description = "Simple command-line snippet manager, written in Go"; @@ -64,16 +60,6 @@ pet = buildGoModule rec { - - subPackages limits the builder from building child packages that have not been listed. If subPackages is not specified, all child packages will be built. - - - - - deleteVendor removes the pre-existing vendor directory and fetches the dependencies. This should only be used if the dependencies included in the vendor folder are broken or incomplete. - - - runVend runs the vend command to generate the vendor directory. This is useful if your code depends on c code and go mod tidy does not include the needed sources to build. @@ -82,12 +68,7 @@ pet = buildGoModule rec { - vendorSha256 can also take null as an input. - - When `null` is used as a value, rather than fetching the dependencies - and vendoring them, we use the vendoring included within the source repo. - If you'd like to not have to update this field on dependency changes, - run `go mod vendor` in your source repo and set 'vendorSha256 = null;' + vendorSha256 can also take null as an input. When `null` is used as a value, rather than fetching the dependencies and vendoring them, we use the vendoring included within the source repo. If you'd like to not have to update this field on dependency changes, run `go mod vendor` in your source repo and set 'vendorSha256 = null;' @@ -106,7 +87,6 @@ deis = buildGoPackage rec { version = "1.13.0"; goPackagePath = "github.com/deis/deis"; - subPackages = [ "client" ]; src = fetchFromGitHub { owner = "deis"; @@ -115,11 +95,7 @@ deis = buildGoPackage rec { sha256 = "1qv9lxqx7m18029lj8cw3k7jngvxs4iciwrypdy0gd2nnghc68sw"; }; - goDeps = ./deps.nix; - - deleteVendor = true; - - buildFlags = [ "--tags" "release" ]; + goDeps = ./deps.nix; } @@ -133,28 +109,10 @@ deis = buildGoPackage rec { - - subPackages limits the builder from building child packages that have not been listed. If subPackages is not specified, all child packages will be built. - - - In this example only github.com/deis/deis/client will be built. - - - goDeps is where the Go dependencies of a Go program are listed as a list of package source identified by Go import path. It could be imported as a separate deps.nix file for readability. The dependency data structure is described below. - - - deleteVendor removes the pre-existing vendor directory. This should only be used if the dependencies included in the vendor folder are broken or incomplete. - - - - - buildFlags is a list of flags passed to the go build command. - - @@ -221,4 +179,70 @@ done + +
+ Attributes used by the builders + + + Both buildGoModule and buildGoPackage can be tweaked to behave slightly differently, if the following attributes are used: + + + + + + buildFlagsArray and buildFlags + + + + These attributes set build flags supported by go build. We recommend using buildFlagsArray. The most common use case of these attributes is to make the resulting executable aware of its own version. For example: + + + buildFlagsArray + + buildFlagsArray = [ + "-ldflags=-X main.Version=${version} -X main.Commit=${version}" + ]; + + + + + + Note: single quotes are not needed. + + + + + buildFlagsArray + + buildFlagsArray = '' + -ldflags= + -X main.Version=${version} + -X main.Commit=${version} + ''; + + + + + + + deleteVendor + + + + Removes the pre-existing vendor directory. This should only be used if the dependencies included in the vendor folder are broken or incomplete. + + + + + + subPackages + + + + Limits the builder from building child packages that have not been listed. If subPackages is not specified, all child packages will be built. + + + + +