diff --git a/doc/language-support.xml b/doc/language-support.xml index 7d016ae6fb97..f33202d45534 100644 --- a/doc/language-support.xml +++ b/doc/language-support.xml @@ -624,6 +624,85 @@ sed -i '/ = data_files/d' setup.py
Go + +The function buildGoPackage builds +standard Go packages. + + +buildGoPackage + +net = buildGoPackage rec { + name = "go.net-${rev}"; + goPackagePath = "code.google.com/p/go.net"; + subPackages = [ "ipv4" "ipv6" ]; + rev = "28ff664507e4"; + src = fetchhg { + inherit rev; + url = "https://${goPackagePath}"; + sha256 = "1lkz4c9pyz3yz2yz18hiycvlfhgy3jxp68bs7mv7bcfpaj729qav"; + }; + propagatedBuildInputs = [ goPackages.text ]; +}; + + + + is an example expression using buildGoPackage, +the following arguments are of special significance to the function: + + + + + + goPackagePath specifies the package's canonical Go import path. + + + + + + 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 code.google.com/p/go.net/ipv4 and + code.google.com/p/go.net/ipv4 will be built. + + + + + + propagatedBuildInputs is where the dependencies of a Go library are + listed. Only libraries should list propagatedBuildInputs. If a standalone + program is being build instead, use buildInputs. If a library's tests require + additional dependencies that are not propagated, they should be listed in buildInputs. + + + + + + + + +Reusable Go libraries may be found in the goPackages set. You can test +build a Go package as follows: + + +$ nix-build -A goPackages.net + + + + + +You may use Go packages installed into the active Nix profiles by adding +the following to your ~/.bashrc: + + +for p in $NIX_PROFILES; do + GOPATH="$p/share/go:$GOPATH" +done + + + To extract dependency information from a Go package in automated way use go2nix.
diff --git a/pkgs/development/compilers/go/1.3.nix b/pkgs/development/compilers/go/1.3.nix index 2f23698059f4..47132023e5af 100644 --- a/pkgs/development/compilers/go/1.3.nix +++ b/pkgs/development/compilers/go/1.3.nix @@ -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"; diff --git a/pkgs/development/compilers/go/1.4.nix b/pkgs/development/compilers/go/1.4.nix index 45fd8e117b22..b1558e56cec7 100644 --- a/pkgs/development/compilers/go/1.4.nix +++ b/pkgs/development/compilers/go/1.4.nix @@ -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"; diff --git a/pkgs/development/compilers/go/setup-hook.sh b/pkgs/development/compilers/go/setup-hook.sh new file mode 100644 index 000000000000..1b91c8312b88 --- /dev/null +++ b/pkgs/development/compilers/go/setup-hook.sh @@ -0,0 +1,5 @@ +addToGoPath() { + addToSearchPath GOPATH $1/share/go +} + +envHooks=(${envHooks[@]} addToGoPath) diff --git a/pkgs/development/go-modules/generic/default.nix b/pkgs/development/go-modules/generic/default.nix new file mode 100644 index 000000000000..6822af54dcd7 --- /dev/null +++ b/pkgs/development/go-modules/generic/default.nix @@ -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 ]; + }; +}) diff --git a/pkgs/tools/networking/cjdns/cjdcmd-ng/default.nix b/pkgs/tools/networking/cjdns/cjdcmd-ng/default.nix new file mode 100644 index 000000000000..fde962c17227 --- /dev/null +++ b/pkgs/tools/networking/cjdns/cjdcmd-ng/default.nix @@ -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; + }; +} \ No newline at end of file diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 134116cba582..98252d8df239 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -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 { diff --git a/pkgs/top-level/go-packages.nix b/pkgs/top-level/go-packages.nix new file mode 100644 index 000000000000..128af92eb70f --- /dev/null +++ b/pkgs/top-level/go-packages.nix @@ -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