go-modules: Add useVend flag to go-modules
This commit is contained in:
parent
148138e9de
commit
95be7b25be
3 changed files with 20 additions and 2 deletions
|
@ -64,6 +64,11 @@ pet = buildGoModule rec {
|
|||
<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>
|
||||
</callout>
|
||||
<callout arearefs='ex-buildGoModule-3'>
|
||||
<para>
|
||||
<varname>runVend</varname> runs the vend command to generate the vendor directory. This is useful if your code depends on c code and go mod tidy does not include the needed sources to build.
|
||||
</para>
|
||||
</callout>
|
||||
</calloutlist>
|
||||
</para>
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -7419,6 +7419,8 @@ in
|
|||
|
||||
vcstool = callPackage ../development/tools/vcstool { };
|
||||
|
||||
vend = callPackage ../development/tools/vend { };
|
||||
|
||||
verilator = callPackage ../applications/science/electronics/verilator {};
|
||||
|
||||
verilog = callPackage ../applications/science/electronics/verilog {};
|
||||
|
|
Loading…
Reference in a new issue