feat(buildGo): Add 'srcOnly' and 'targets' parameters for external
Adds two new parameters to buildGo.external: * `srcOnly` toggles whether the created derivation should contain only the source code, or the built package. This is useful in situations where some sub-packages of a larger package are needed and the build should be deferred to the package depending on them. It defaults to false, meaning that external packages are built by default. * `targets` controls which "sub-packages" of the target package are built. It defaults to building all sub-packages.
This commit is contained in:
parent
7d26550c11
commit
8b6b08b814
1 changed files with 4 additions and 4 deletions
|
@ -90,7 +90,7 @@ let
|
||||||
#
|
#
|
||||||
# Contrary to other functions, `src` is expected to point at a
|
# Contrary to other functions, `src` is expected to point at a
|
||||||
# single directory containing the root of the external library.
|
# single directory containing the root of the external library.
|
||||||
external = { path, src, deps ? [] }:
|
external = { path, src, deps ? [], srcOnly ? false, targets ? [ "..." ] }:
|
||||||
let
|
let
|
||||||
name = pathToName path;
|
name = pathToName path;
|
||||||
uniqueDeps = allDeps deps;
|
uniqueDeps = allDeps deps;
|
||||||
|
@ -106,7 +106,7 @@ let
|
||||||
mkdir -p gopath $out
|
mkdir -p gopath $out
|
||||||
export GOPATH=$PWD/gopath
|
export GOPATH=$PWD/gopath
|
||||||
ln -s ${gopathSrc} gopath/src
|
ln -s ${gopathSrc} gopath/src
|
||||||
${go}/bin/go install ${path}/...
|
${go}/bin/go install ${spaceOut (map (t: path + "/" + t) targets)}
|
||||||
|
|
||||||
if [[ -d gopath/pkg/linux_amd64 ]]; then
|
if [[ -d gopath/pkg/linux_amd64 ]]; then
|
||||||
echo "Installing Go packages for ${path}"
|
echo "Installing Go packages for ${path}"
|
||||||
|
@ -118,10 +118,10 @@ let
|
||||||
mv gopath/bin $out/bin
|
mv gopath/bin $out/bin
|
||||||
fi
|
fi
|
||||||
'';
|
'';
|
||||||
in symlinkJoin {
|
in (if srcOnly then gopathSrc else symlinkJoin {
|
||||||
name = "goext-${name}";
|
name = "goext-${name}";
|
||||||
paths = [ gopathSrc gopathPkg ];
|
paths = [ gopathSrc gopathPkg ];
|
||||||
} // { goDeps = uniqueDeps; };
|
}) // { goDeps = uniqueDeps; };
|
||||||
|
|
||||||
# Protobuf & gRPC integration requires these dependencies:
|
# Protobuf & gRPC integration requires these dependencies:
|
||||||
proto-go-src = fetchFromGitHub {
|
proto-go-src = fetchFromGitHub {
|
||||||
|
|
Loading…
Reference in a new issue