From 14d49ddc40f6631a2b588c4d35e0ce265a4d68e1 Mon Sep 17 00:00:00 2001 From: Kamil Chmielewski Date: Fri, 10 Jun 2016 20:26:13 +0200 Subject: [PATCH] buildGoPackage: updated docs for goPackages after rework in https://github.com/NixOS/nixpkgs/pull/16017 --- doc/languages-frameworks/go.xml | 143 ++++++++++++++++++++------------ 1 file changed, 88 insertions(+), 55 deletions(-) diff --git a/doc/languages-frameworks/go.xml b/doc/languages-frameworks/go.xml index d715765f6a14..520c338b9a87 100644 --- a/doc/languages-frameworks/go.xml +++ b/doc/languages-frameworks/go.xml @@ -5,27 +5,29 @@ Go The function buildGoPackage builds -standard Go packages. +standard Go programs. buildGoPackage -net = buildGoPackage rec { - name = "go.net-${rev}"; - goPackagePath = "golang.org/x/net"; - subPackages = [ "ipv4" "ipv6" ]; - rev = "e0403b4e005"; +deis = buildGoPackage rec { + name = "deis-${version}"; + version = "1.13.0"; + + goPackagePath = "github.com/deis/deis"; + subPackages = [ "client" ]; + src = fetchFromGitHub { - inherit rev; - owner = "golang"; - repo = "net"; - sha256 = "1g7cjzw4g4301a3yqpbk8n1d4s97sfby2aysl275x04g0zh8jxqp"; + owner = "deis"; + repo = "deis"; + rev = "v${version}"; + sha256 = "1qv9lxqx7m18029lj8cw3k7jngvxs4iciwrypdy0gd2nnghc68sw"; }; - goPackageAliases = [ "code.google.com/p/go.net" ]; - propagatedBuildInputs = [ goPackages.text ]; - buildFlags = "--tags release"; - disabled = isGo13; -}; + + goDeps = ./deps.json; + + buildFlags = "--tags release"; +} @@ -47,64 +49,94 @@ the following arguments are of special significance to the function: packages will be built. - In this example only code.google.com/p/go.net/ipv4 and - code.google.com/p/go.net/ipv6 will be built. + In this example only github.com/deis/deis/client will be built. - goPackageAliases is a list of alternative import paths - that are valid for this library. - Packages that depend on this library will automatically rename - import paths that match any of the aliases to goPackagePath. - - - In this example imports will be renamed from - code.google.com/p/go.net to - golang.org/x/net in every package that depend on the - go.net library. + goDeps is where the Go dependencies of a Go program are listed + in a JSON format described below. - - propagatedBuildInputs is where the dependencies of a Go library are - listed. Only libraries should list propagatedBuildInputs. If a standalone - program is being built instead, use buildInputs. If a library's tests require - additional dependencies that are not propagated, they should be listed in buildInputs. - - - - buildFlags is a list of flags passed to the go build command. - - - If disabled is true, - nix will refuse to build this package. - - - In this example the package will not be built for go 1.3. The isGo13 - is an utility function that returns true if go used to build the - package has version 1.3.x. - - - - -Reusable Go libraries may be found in the goPackages set. You can test -build a Go package as follows: +The goDeps attribute should point to a JSON file that defines which Go libraries + are needed and should be included in GOPATH for buildPhase. - -$ nix-build -A goPackages.net - + + +deps.json + +[ + { + "goPackagePath": "gopkg.in/yaml.v2", + "fetch": { + "type": "git", + "url": "https://gopkg.in/yaml.v2", + "rev": "a83829b6f1293c91addabc89d0571c246397bbf4", + "sha256": "1m4dsmk90sbi17571h6pld44zxz7jc4lrnl4f27dpd1l8g5xvjhh" + } + }, + { + "include": "../../libs.json", + "packages": [ + "github.com/docopt/docopt-go", + "golang.org/x/crypto", + ] + } +] + + + + + + + + + + goDeps is a list of Go dependencies. + + + + + + goPackagePath specifies Go package import path. + + + + + + fetch type that needs to be used to get package source. If git + is used there should be url, rev and sha256 + defined next to it. + + + + + + include could be used to reuse goDeps between Go programs. + There is a common libs set in <nixpkgs/pkgs/development/go-modules/libs.json> + with pinned versions of many packages that you can reuse. + + + + + + packages enumerates all Go packages that will be imported from included file. + + + + @@ -119,6 +151,7 @@ done - To extract dependency information from a Go package in automated way use go2nix. +To extract dependency information from a Go package in automated way use go2nix. + It can produce complete derivation and goDeps file for Go programs.