From 3a5e10e37f297e3df0da656d08ea211aa9e1187a Mon Sep 17 00:00:00 2001 From: "William A. Kennington III" Date: Thu, 14 May 2015 17:30:55 -0700 Subject: [PATCH] buildGoPackage: Support adding extra sources --- .../go-modules/generic/default.nix | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/pkgs/development/go-modules/generic/default.nix b/pkgs/development/go-modules/generic/default.nix index 76828784a9d..fce307e063c 100644 --- a/pkgs/development/go-modules/generic/default.nix +++ b/pkgs/development/go-modules/generic/default.nix @@ -5,7 +5,14 @@ # Go import path of the package , goPackagePath -, meta ? {}, ... } @ args: +# Extra sources to include in the gopath +, extraSrcs ? [ ] + +, meta ? {}, ... } @ args': + +let + args = lib.filterAttrs (name: _: name != "extraSrcs") args'; +in go.stdenv.mkDerivation ( args // { name = "go${go.meta.branch}-${name}"; @@ -14,10 +21,20 @@ go.stdenv.mkDerivation ( args // { configurePhase = args.configurePhase or '' runHook preConfigure + # Extract the source cd "$NIX_BUILD_TOP" mkdir -p "go/src/$(dirname "$goPackagePath")" mv "$sourceRoot" "go/src/$goPackagePath" + '' + lib.flip lib.concatMapStrings extraSrcs ({ src, goPackagePath }: '' + mkdir extraSrc + (cd extraSrc; unpackFile "${src}") + mkdir -p "go/src/$(dirname "${goPackagePath}")" + chmod -R u+w extraSrc/* + mv extraSrc/* "go/src/${goPackagePath}" + rmdir extraSrc + + '') + '' GOPATH=$NIX_BUILD_TOP/go:$GOPATH runHook postConfigure