go-modules: Add useVend flag to go-modules

This commit is contained in:
Colin L Rice
2020-07-28 21:11:28 -04:00
parent 148138e9de
commit 95be7b25be
3 changed files with 20 additions and 2 deletions
@@ -1,4 +1,4 @@
{ go, cacert, git, lib, removeReferencesTo, stdenv }:
{ go, cacert, git, lib, removeReferencesTo, stdenv, vend }:
{ name ? "${args'.pname}-${args'.version}"
, src
@@ -20,6 +20,9 @@
, vendorSha256
# Whether to delete the vendor folder supplied with the source.
, deleteVendor ? false
# Whether to run the vend tool to regenerate the vendor directory.
# This is useful if any dependency contain C files.
, runVend ? false
, modSha256 ? null
@@ -48,6 +51,8 @@ let
deleteFlag = if deleteVendor then "true" else "false";
vendCommand = if runVend then "${vend}/bin/vend" else "false";
go-modules = if vendorSha256 != null then go.stdenv.mkDerivation (let modArgs = {
name = "${name}-go-modules";
@@ -87,7 +92,13 @@ let
echo "vendor folder exists, please set 'vendorSha256=null;' or 'deleteVendor=true;' in your expression"
exit 10
fi
go mod vendor
if [ ${vendCommand} != "false" ]; then
echo running vend to rewrite vendor folder
${vendCommand}
else
go mod vendor
fi
mkdir -p vendor
runHook postBuild