diff --git a/doc/languages-frameworks/go.section.md b/doc/languages-frameworks/go.section.md index c697a6908751a..cf1808414234c 100644 --- a/doc/languages-frameworks/go.section.md +++ b/doc/languages-frameworks/go.section.md @@ -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 diff --git a/pkgs/build-support/go/module.nix b/pkgs/build-support/go/module.nix index 9bfb5858ad403..2b63d9e9f5336 100644 --- a/pkgs/build-support/go/module.nix +++ b/pkgs/build-support/go/module.nix @@ -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"; @@ -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;