new Go support function 'buildGoPackage'
add a setupHook to the Go compiler that builds a GOPATH new buildGoPackage function that overides the phases of stdenv
This commit is contained in:
parent
2d19af84de
commit
faa5dccab8
@ -624,6 +624,85 @@ sed -i '/ = data_files/d' setup.py</programlisting>
|
||||
|
||||
|
||||
<section xml:id="ssec-language-go"><title>Go</title>
|
||||
|
||||
<para>The function <varname>buildGoPackage</varname> builds
|
||||
standard Go packages.
|
||||
</para>
|
||||
|
||||
<example xml:id='ex-buildGoPackage'><title>buildGoPackage</title>
|
||||
<programlisting>
|
||||
net = buildGoPackage rec {
|
||||
name = "go.net-${rev}";
|
||||
goPackagePath = "code.google.com/p/go.net"; <co xml:id='ex-buildGoPackage-1' />
|
||||
subPackages = [ "ipv4" "ipv6" ]; <co xml:id='ex-buildGoPackage-2' />
|
||||
rev = "28ff664507e4";
|
||||
src = fetchhg {
|
||||
inherit rev;
|
||||
url = "https://${goPackagePath}";
|
||||
sha256 = "1lkz4c9pyz3yz2yz18hiycvlfhgy3jxp68bs7mv7bcfpaj729qav";
|
||||
};
|
||||
propagatedBuildInputs = [ goPackages.text ]; <co xml:id='ex-buildGoPackage-3' />
|
||||
};
|
||||
</programlisting>
|
||||
</example>
|
||||
|
||||
<para><xref linkend='ex-buildGoPackage'/> is an example expression using buildGoPackage,
|
||||
the following arguments are of special significance to the function:
|
||||
|
||||
<calloutlist>
|
||||
|
||||
<callout arearefs='ex-buildGoPackage-1'>
|
||||
<para>
|
||||
<varname>goPackagePath</varname> specifies the package's canonical Go import path.
|
||||
</para>
|
||||
</callout>
|
||||
|
||||
<callout arearefs='ex-buildGoPackage-2'>
|
||||
<para>
|
||||
<varname>subPackages</varname> limits the builder from building child packages that
|
||||
have not been listed. If <varname>subPackages</varname> is not specified, all child
|
||||
packages will be built.
|
||||
</para>
|
||||
<para>
|
||||
In this example only <literal>code.google.com/p/go.net/ipv4</literal> and
|
||||
<literal>code.google.com/p/go.net/ipv4</literal> will be built.
|
||||
</para>
|
||||
</callout>
|
||||
|
||||
<callout arearefs='ex-buildGoPackage-3'>
|
||||
<para>
|
||||
<varname>propagatedBuildInputs</varname> is where the dependencies of a Go library are
|
||||
listed. Only libraries should list <varname>propagatedBuildInputs</varname>. If a standalone
|
||||
program is being build instead, use <varname>buildInputs</varname>. If a library's tests require
|
||||
additional dependencies that are not propagated, they should be listed in <varname>buildInputs</varname>.
|
||||
</para>
|
||||
</callout>
|
||||
|
||||
</calloutlist>
|
||||
|
||||
</para>
|
||||
|
||||
<para>
|
||||
Reusable Go libraries may be found in the <varname>goPackages</varname> set. You can test
|
||||
build a Go package as follows:
|
||||
|
||||
<screen>
|
||||
$ nix-build -A goPackages.net
|
||||
</screen>
|
||||
|
||||
</para>
|
||||
|
||||
<para>
|
||||
You may use Go packages installed into the active Nix profiles by adding
|
||||
the following to your ~/.bashrc:
|
||||
|
||||
<screen>
|
||||
for p in $NIX_PROFILES; do
|
||||
GOPATH="$p/share/go:$GOPATH"
|
||||
done
|
||||
</screen>
|
||||
</para>
|
||||
|
||||
<para>To extract dependency information from a Go package in automated way use <link xlink:href="https://github.com/cstrahan/go2nix">go2nix</link>.</para>
|
||||
</section>
|
||||
|
||||
|
@ -81,6 +81,7 @@ stdenv.mkDerivation {
|
||||
installPhase = ''
|
||||
export CC=cc
|
||||
mkdir -p "$out/bin"
|
||||
unset GOPATH
|
||||
export GOROOT="$(pwd)/"
|
||||
export GOBIN="$out/bin"
|
||||
export PATH="$GOBIN:$PATH"
|
||||
@ -99,6 +100,8 @@ stdenv.mkDerivation {
|
||||
cp ./misc/emacs/* $out/share/emacs/site-lisp/
|
||||
'';
|
||||
|
||||
setupHook = ./setup-hook.sh;
|
||||
|
||||
meta = {
|
||||
homepage = http://golang.org/;
|
||||
description = "The Go Programming language";
|
||||
|
@ -95,6 +95,8 @@ stdenv.mkDerivation {
|
||||
go test -v $TOOL_ROOT/cover $TOOL_ROOT/vet # $TOOL_ROOT/godoc
|
||||
'';
|
||||
|
||||
setupHook = ./setup-hook.sh;
|
||||
|
||||
meta = {
|
||||
homepage = http://golang.org/;
|
||||
description = "The Go Programming language";
|
||||
|
5
pkgs/development/compilers/go/setup-hook.sh
Normal file
5
pkgs/development/compilers/go/setup-hook.sh
Normal file
@ -0,0 +1,5 @@
|
||||
addToGoPath() {
|
||||
addToSearchPath GOPATH $1/share/go
|
||||
}
|
||||
|
||||
envHooks=(${envHooks[@]} addToGoPath)
|
84
pkgs/development/go-modules/generic/default.nix
Normal file
84
pkgs/development/go-modules/generic/default.nix
Normal file
@ -0,0 +1,84 @@
|
||||
{ go }:
|
||||
|
||||
{ name, buildInputs ? []
|
||||
|
||||
# Go import path of the package
|
||||
, goPackagePath
|
||||
|
||||
, meta ? {}, ... } @ args:
|
||||
|
||||
go.stdenv.mkDerivation ( args // {
|
||||
name = "${go.name}-${name}";
|
||||
buildInputs = [ go ] ++ buildInputs;
|
||||
|
||||
configurePhase = args.configurePhase or ''
|
||||
runHook preConfigure
|
||||
|
||||
cd "$NIX_BUILD_TOP"
|
||||
mkdir -p "go/src/$(dirname "$goPackagePath")"
|
||||
mv "$sourceRoot" "go/src/$goPackagePath"
|
||||
|
||||
GOPATH=$NIX_BUILD_TOP/go:$GOPATH
|
||||
|
||||
runHook postConfigure
|
||||
'';
|
||||
|
||||
buildPhase = args.buildPhase or ''
|
||||
runHook preBuild
|
||||
|
||||
if [ -n "$subPackages" ] ; then
|
||||
for p in $subPackages ; do
|
||||
go install -p $NIX_BUILD_CORES -v $goPackagePath/$p
|
||||
done
|
||||
else
|
||||
find . -type d | while read d; do
|
||||
for i in $d/*.go; do
|
||||
go install -p $NIX_BUILD_CORES -v $d
|
||||
break
|
||||
done
|
||||
done
|
||||
fi
|
||||
|
||||
runHook postBuild
|
||||
'';
|
||||
|
||||
checkPhase = args.checkPhase or ''
|
||||
runHook preCheck
|
||||
|
||||
if [ -n "$subPackages" ] ; then
|
||||
for p in $subPackages ; do
|
||||
go test -p $NIX_BUILD_CORES -v $goPackagePath/$p
|
||||
done
|
||||
else
|
||||
find . -type d | while read d; do
|
||||
for i in $d/*_test.go; do
|
||||
go test -p $NIX_BUILD_CORES -v $d
|
||||
break
|
||||
done
|
||||
done
|
||||
fi
|
||||
|
||||
runHook postCheck
|
||||
'';
|
||||
|
||||
installPhase = args.installPhase or ''
|
||||
runHook preInstall
|
||||
|
||||
local dir
|
||||
for d in pkg src; do
|
||||
mkdir -p $out/share/go
|
||||
dir="$NIX_BUILD_TOP/go/$d"
|
||||
[ -e "$dir" ] && cp -r $dir $out/share/go
|
||||
done
|
||||
|
||||
dir="$NIX_BUILD_TOP/go/bin"
|
||||
[ -e "$dir" ] && cp -r $dir $out
|
||||
|
||||
runHook postInstall
|
||||
'';
|
||||
|
||||
meta = meta // {
|
||||
# add an extra maintainer to every package
|
||||
maintainers = (meta.maintainers or []) ++ [ go.stdenv.lib.maintainers.emery ];
|
||||
};
|
||||
})
|
42
pkgs/tools/networking/cjdns/cjdcmd-ng/default.nix
Normal file
42
pkgs/tools/networking/cjdns/cjdcmd-ng/default.nix
Normal file
@ -0,0 +1,42 @@
|
||||
{ stdenv, buildGoPackage, goPackages, fetchurl, cjdns }:
|
||||
|
||||
with goPackages;
|
||||
|
||||
let
|
||||
go-cjdns = buildGoPackage rec {
|
||||
version = "2.1.0";
|
||||
name = "go-cjdns-${version}";
|
||||
|
||||
goPackagePath = "github.com/ehmry/go-cjdns";
|
||||
subPackages = [ "admin" "config" "key" ];
|
||||
|
||||
src = fetchurl {
|
||||
url = "https://${goPackagePath}/archive/v${version}.tar.gz";
|
||||
name = "${name}.tar.gz";
|
||||
sha256 = "1ys47zdz9dv45w5j31z020z72yy6yrfas9c5777mwl42925s9bnf";
|
||||
};
|
||||
buildInputs = [ goconvey ];
|
||||
propagatedBuildInputs = [ crypto go-bencode ];
|
||||
};
|
||||
in
|
||||
let version = "0.8.3"; in
|
||||
buildGoPackage rec {
|
||||
name = "cjdcmd-ng-${version}";
|
||||
goPackagePath = "github.com/ehmry/cjdcmd-ng";
|
||||
|
||||
src = fetchurl {
|
||||
url = "https://${goPackagePath}/archive/v${version}.tar.gz";
|
||||
name = "${name}.tar.gz";
|
||||
sha256 = "10j2f00byz4vrcyk8mxw5f9l8ikkdmi8044mnnwndkjky3m9xj43";
|
||||
};
|
||||
|
||||
buildInputs = [ go-cjdns cobra ];
|
||||
|
||||
meta = with stdenv.lib; {
|
||||
description = "Utility for interacting with CJDNS";
|
||||
homepage = https://github.com/ehmry/cjdcmd-ng;
|
||||
mantainers = with maintainers; [ emery ];
|
||||
license = licenses.gpl3Plus;
|
||||
platforms = cjdns.meta.platforms;
|
||||
};
|
||||
}
|
@ -878,6 +878,7 @@ let
|
||||
chunksync = callPackage ../tools/backup/chunksync { };
|
||||
|
||||
cjdns = callPackage ../tools/networking/cjdns { };
|
||||
cjdcmd-ng = callPackage ../tools/networking/cjdns/cjdcmd-ng { };
|
||||
|
||||
cksfv = callPackage ../tools/networking/cksfv { };
|
||||
|
||||
@ -7589,6 +7590,26 @@ let
|
||||
|
||||
yuicompressor = callPackage ../development/tools/yuicompressor { };
|
||||
|
||||
### DEVELOPMENT / GO MODULES
|
||||
|
||||
go13Packages = recurseIntoAttrs (callPackage ./go-packages.nix {
|
||||
go = go_1_3;
|
||||
buildGoPackage = import ../development/go-modules/generic {
|
||||
go = go_1_3;
|
||||
};
|
||||
overrides = (config.goPackageOverrides or (p: {})) pkgs;
|
||||
});
|
||||
|
||||
go14Packages = recurseIntoAttrs (callPackage ./go-packages.nix {
|
||||
go = go_1_4;
|
||||
buildGoPackage = import ../development/go-modules/generic {
|
||||
go = go_1_4;
|
||||
};
|
||||
overrides = (config.goPackageOverrides or (p: {})) pkgs;
|
||||
});
|
||||
|
||||
goPackages = go14Packages;
|
||||
|
||||
### DEVELOPMENT / LISP MODULES
|
||||
|
||||
asdf = callPackage ../development/lisp-modules/asdf {
|
||||
|
139
pkgs/top-level/go-packages.nix
Normal file
139
pkgs/top-level/go-packages.nix
Normal file
@ -0,0 +1,139 @@
|
||||
/* This file defines the composition for Go packages. */
|
||||
|
||||
{ overrides, stdenv, go, buildGoPackage
|
||||
,fetchgit, fetchhg, fetchurl, fetchFromGitHub }:
|
||||
|
||||
let self = _self // overrides; _self = with self; {
|
||||
|
||||
inherit go buildGoPackage;
|
||||
|
||||
## OFFICIAL GO PACKAGES
|
||||
|
||||
image = buildGoPackage rec {
|
||||
rev = "490b1ad139b3";
|
||||
name = "go.image-${rev}";
|
||||
goPackagePath = "code.google.com/p/go.image";
|
||||
src = fetchhg {
|
||||
inherit rev;
|
||||
url = "https://${goPackagePath}";
|
||||
sha256 = "02m6ifwby2fi88njarbbb6dimwg0pd2b6llkgyadh4b9wzp2vy4r";
|
||||
};
|
||||
};
|
||||
|
||||
net = buildGoPackage rec {
|
||||
rev = "3338d5f109e9";
|
||||
name = "go.net-${rev}";
|
||||
goPackagePath = "code.google.com/p/go.net";
|
||||
src = fetchhg {
|
||||
inherit rev;
|
||||
url = "https://${goPackagePath}";
|
||||
sha256 = "0yz807y3ac07x3nf0qlaw1w1i6asynrpyssjl8jyv3pplww0qj7i";
|
||||
};
|
||||
propagatedBuildInputs = [ text ];
|
||||
};
|
||||
|
||||
text = buildGoPackage rec {
|
||||
rev = "024681b033be";
|
||||
name = "go.text-${rev}";
|
||||
goPackagePath = "code.google.com/p/go.text";
|
||||
src = fetchhg {
|
||||
inherit rev;
|
||||
url = "https://${goPackagePath}";
|
||||
sha256 = "19px5pw5mvwjb7ymivfkkkr6cyl2npv834jxlr6y0x5ca1djhsci";
|
||||
};
|
||||
doCheck = false;
|
||||
};
|
||||
|
||||
## THIRD PARTY
|
||||
|
||||
cobra = buildGoPackage rec {
|
||||
date = "20140617";
|
||||
rev = "10a8494a87448bf5003222d9974f166437e7f042";
|
||||
name = "cobra-${date}-${stdenv.lib.strings.substring 0 7 rev}";
|
||||
goPackagePath = "github.com/spf13/cobra";
|
||||
src = fetchgit {
|
||||
inherit rev;
|
||||
url = "https://${goPackagePath}.git";
|
||||
sha256 = "1ydcccx0zdswca4v9hfmrn8ck42h485hy3wrd9k7y6mra3r6c08j";
|
||||
};
|
||||
propagatedBuildInputs = [ pflag ];
|
||||
};
|
||||
|
||||
goconvey = buildGoPackage rec {
|
||||
version = "1.5.0";
|
||||
name = "goconvey-${version}";
|
||||
goPackagePath = "github.com/smartystreets/goconvey";
|
||||
src = fetchurl {
|
||||
name = "${name}.tar.gz";
|
||||
url = "https://github.com/smartystreets/goconvey/archive/${version}.tar.gz";
|
||||
sha256 = "0g3965cb8kg4kf9b0klx4pj9ycd7qwbw1jqjspy6i5d4ccd6mby4";
|
||||
};
|
||||
buildInputs = [ oglematchers ];
|
||||
doCheck = false; # please check again
|
||||
};
|
||||
|
||||
go-bencode = buildGoPackage rec {
|
||||
version = "1.1.1";
|
||||
name = "go-bencode-${version}";
|
||||
goPackagePath = "github.com/ehmry/go-bencode";
|
||||
|
||||
src = fetchurl {
|
||||
url = "https://${goPackagePath}/archive/v${version}.tar.gz";
|
||||
sha256 = "0y2kz2sg1f7mh6vn70kga5d0qhp04n01pf1w7k6s8j2nm62h24j6";
|
||||
};
|
||||
};
|
||||
|
||||
oglematchers = buildGoPackage rec {
|
||||
rev = "4fc24f97b5b74022c2a3f4ca7eed57ca29083d3e";
|
||||
name = "oglematchers-${stdenv.lib.strings.substring 0 7 rev}";
|
||||
goPackagePath = "github.com/jacobsa/oglematchers";
|
||||
src = fetchgit {
|
||||
inherit rev;
|
||||
url = "https://${goPackagePath}.git";
|
||||
sha256 = "4075ede31601adf8c4e92739693aebffa3718c641dfca75b09cf6b4bd6c26cc0";
|
||||
};
|
||||
#goTestInputs = [ ogletest ];
|
||||
doCheck = false; # infinite recursion
|
||||
};
|
||||
|
||||
oglemock = buildGoPackage rec {
|
||||
rev = "d054ecee522bdce4481690cdeb09d1b4c44da4e1";
|
||||
name = "oglemock-${stdenv.lib.strings.substring 0 7 rev}";
|
||||
goPackagePath = "github.com/jacobsa/oglemock";
|
||||
src = fetchgit {
|
||||
inherit rev;
|
||||
url = "https://${goPackagePath}.git";
|
||||
sha256 = "685e7fc4308d118ae25467ba84c64754692a7772c77c197f38d8c1b63ea81da2";
|
||||
};
|
||||
buildInputs = [ oglematchers ];
|
||||
#goTestInputs = [ ogletest ];
|
||||
doCheck = false; # infinite recursion
|
||||
};
|
||||
|
||||
ogletest = buildGoPackage rec {
|
||||
rev = "7de485607c3f215cf92c1f793b5d5a7de46ec3c7";
|
||||
name = "ogletest-${stdenv.lib.strings.substring 0 7 rev}";
|
||||
goPackagePath = "github.com/jacobsa/ogletest";
|
||||
src = fetchgit {
|
||||
inherit rev;
|
||||
url = "https://${goPackagePath}.git";
|
||||
sha256 = "0cfc43646d59dcea5772320f968aef2f565fb5c46068d8def412b8f635365361";
|
||||
};
|
||||
buildInputs = [ oglemock oglematchers ];
|
||||
doCheck = false; # check this again
|
||||
};
|
||||
|
||||
pflag = buildGoPackage rec {
|
||||
date = "20131112";
|
||||
rev = "94e98a55fb412fcbcfc302555cb990f5e1590627";
|
||||
name = "pflag-${date}-${stdenv.lib.strings.substring 0 7 rev}";
|
||||
goPackagePath = "github.com/spf13/pflag";
|
||||
src = fetchgit {
|
||||
inherit rev;
|
||||
url = "https://${goPackagePath}.git";
|
||||
sha256 = "0z8nzdhj8nrim8fz11magdl0wxnisix9p2kcvn5kkb3bg8wmxhbg";
|
||||
};
|
||||
doCheck = false; # bad import path in tests
|
||||
};
|
||||
|
||||
}; in self
|
Loading…
Reference in New Issue
Block a user