buildGoModule: refactor GO111MODULE

This commit is contained in:
zowoq
2023-08-02 01:08:27 +10:00
parent 9a424242d7
commit 41ccfa322e
+4 -4
View File
@@ -52,6 +52,8 @@ assert (args' ? vendorHash && args' ? vendorSha256) -> throw "both `vendorHash`
let
args = removeAttrs args' [ "overrideModAttrs" "vendorSha256" "vendorHash" ];
GO111MODULE = "on";
goModules = if (vendorHash == null) then "" else
(stdenv.mkDerivation {
name = "${name}-go-modules";
@@ -60,6 +62,7 @@ let
inherit (args) src;
inherit (go) GOOS GOARCH;
inherit GO111MODULE;
# The following inheritence behavior is not trivial to expect, and some may
# argue it's not ideal. Changing it may break vendor hashes in Nixpkgs and
@@ -73,8 +76,6 @@ let
postBuild = args.modPostBuild or "";
sourceRoot = args.sourceRoot or "";
GO111MODULE = "on";
impureEnvVars = lib.fetchers.proxyImpureEnvVars ++ [
"GIT_PROXY_COMMAND"
"SOCKS_SERVER"
@@ -149,9 +150,8 @@ let
inherit (go) GOOS GOARCH;
GO111MODULE = "on";
GOFLAGS = lib.optionals (!proxyVendor) [ "-mod=vendor" ] ++ lib.optionals (!allowGoReference) [ "-trimpath" ];
inherit CGO_ENABLED enableParallelBuilding;
inherit CGO_ENABLED enableParallelBuilding GO111MODULE;
configurePhase = args.configurePhase or (''
runHook preConfigure