Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

buildGoModule: correct spelling in documentation and simplify the go-modules structure #234032

Merged
merged 2 commits into from
May 27, 2023
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.
Jump to
Jump to file
Failed to load files.
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