Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion doc/languages-frameworks/go.section.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ In the following is an example expression using `buildGoModule`, the following a
To avoid updating this field when dependencies change, run `go mod vendor` in your source repo and set `vendorHash = null;`

To obtain the actual hash, set `vendorHash = lib.fakeSha256;` and run the build ([more details here](#sec-source-hashes)).
- `proxyVendor`: Fetches (go mod download) and proxies 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 or if any dependency has case-insensitive conflicts which will produce platform dependant `vendorHash` checksums.
- `proxyVendor`: Fetches (go mod download) and proxies 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 or if any dependency has case-insensitive conflicts which will produce platform-dependent `vendorHash` checksums.
- `modPostBuild`: Shell commands to run after the build of the go-modules executes `go mod vendor`, and before calculating fixed output derivation's `vendorHash` (or `vendorSha256`). Note that if you change this attribute, you need to update `vendorHash` (or `vendorSha256`) attribute.

```nix
Expand Down
15 changes: 7 additions & 8 deletions pkgs/build-support/go/module.nix
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ assert (args' ? vendorHash && args' ? vendorSha256) -> throw "both `vendorHash`
let
args = removeAttrs args' [ "overrideModAttrs" "vendorSha256" "vendorHash" ];

go-modules = if (vendorHash != null) then stdenv.mkDerivation (let modArgs = {
go-modules = if (vendorHash == null) then "" else
(stdenv.mkDerivation {

name = "${name}-go-modules";

Expand Down Expand Up @@ -138,13 +139,11 @@ let
'';

dontFixup = true;
}; in modArgs // (
{
outputHashMode = "recursive";
outputHash = vendorHash;
outputHashAlgo = if args' ? vendorSha256 || vendorHash == "" then "sha256" else null;
}
) // overrideModAttrs modArgs) else "";

outputHashMode = "recursive";
outputHash = vendorHash;
outputHashAlgo = if args' ? vendorSha256 || vendorHash == "" then "sha256" else null;
}).overrideAttrs overrideModAttrs;

package = stdenv.mkDerivation (args // {
nativeBuildInputs = [ go ] ++ nativeBuildInputs;
Expand Down