Skip to content

Commit 7e823e9

Browse files
authored
docs: improve go builder comments in module.nix (#341561)
2 parents 86326ef + a808f82 commit 7e823e9

File tree

1 file changed

+24
-18
lines changed

1 file changed

+24
-18
lines changed

pkgs/build-support/go/module.nix

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,62 @@
11
{ go, cacert, git, lib, stdenv }:
22

33
{ name ? "${args'.pname}-${args'.version}"
4+
# The source used to build the derivation.
45
, src
6+
# Native build inputs used for the derivation.
57
, nativeBuildInputs ? [ ]
68
, passthru ? { }
79
, patches ? [ ]
810

9-
# A function to override the goModules derivation
11+
# A function to override the `goModules` derivation.
1012
, overrideModAttrs ? (finalAttrs: previousAttrs: { })
1113

12-
# path to go.mod and go.sum directory
14+
# Directory to the `go.mod` and `go.sum` relative to the `src`.
1315
, modRoot ? "./"
1416

15-
# vendorHash is the SRI hash of the vendored dependencies
16-
#
17-
# if vendorHash is null, then we won't fetch any dependencies and
18-
# rely on the vendor folder within the source.
17+
# The SRI hash of the vendored dependencies.
18+
# If `vendorHash` is `null`, no dependencies are fetched and
19+
# the build relies on the vendor folder within the source.
1920
, vendorHash ? throw (
2021
if args'?vendorSha256 then
2122
"buildGoModule: Expect vendorHash instead of vendorSha256"
2223
else
2324
"buildGoModule: vendorHash is missing"
2425
)
26+
2527
# Whether to delete the vendor folder supplied with the source.
2628
, deleteVendor ? false
29+
2730
# Whether to fetch (go mod download) and proxy the vendor directory.
2831
# This is useful if your code depends on c code and go mod tidy does not
2932
# include the needed sources to build or if any dependency has case-insensitive
3033
# conflicts which will produce platform dependant `vendorHash` checksums.
3134
, proxyVendor ? false
3235

33-
# We want parallel builds by default
36+
# We want parallel builds by default.
3437
, enableParallelBuilding ? true
3538

3639
# Do not enable this without good reason
37-
# IE: programs coupled with the compiler
40+
# IE: programs coupled with the compiler.
3841
, allowGoReference ? false
3942

43+
# Go env. variable to enable CGO.
4044
, CGO_ENABLED ? go.CGO_ENABLED
4145

46+
# Meta data for the final derivation.
4247
, meta ? { }
4348

44-
# Not needed with buildGoModule
49+
# Not needed with `buildGoModule`.
4550
, goPackagePath ? ""
4651

52+
# Go linker flags.
4753
, ldflags ? [ ]
48-
54+
# Go build flags.
4955
, GOFLAGS ? [ ]
5056

51-
# needed for buildFlags{,Array} warning
52-
, buildFlags ? ""
53-
, buildFlagsArray ? ""
57+
# Needed for buildFlags{,Array} warning
58+
, buildFlags ? "" # deprecated
59+
, buildFlagsArray ? "" # deprecated
5460

5561
, ...
5662
}@args':
@@ -79,10 +85,10 @@ in
7985
inherit (go) GOOS GOARCH;
8086
inherit GO111MODULE GOTOOLCHAIN;
8187

82-
# The following inheritence behavior is not trivial to expect, and some may
88+
# The following inheritance behavior is not trivial to expect, and some may
8389
# argue it's not ideal. Changing it may break vendor hashes in Nixpkgs and
8490
# out in the wild. In anycase, it's documented in:
85-
# doc/languages-frameworks/go.section.md
91+
# doc/languages-frameworks/go.section.md.
8692
prePatch = finalAttrs.prePatch or "";
8793
patches = finalAttrs.patches or [ ];
8894
patchFlags = finalAttrs.patchFlags or [ ];
@@ -160,8 +166,8 @@ in
160166

161167
outputHashMode = "recursive";
162168
outputHash = finalAttrs.vendorHash;
163-
# Handle empty vendorHash; avoid
164-
# error: empty hash requires explicit hash algorithm
169+
# Handle empty `vendorHash`; avoid error:
170+
# empty hash requires explicit hash algorithm.
165171
outputHashAlgo = if finalAttrs.vendorHash == "" then "sha256" else null;
166172
# in case an overlay clears passthru by accident, don't fail evaluation
167173
}).overrideAttrs (finalAttrs.passthru.overrideModAttrs or overrideModAttrs);
@@ -323,7 +329,7 @@ in
323329
} // passthru;
324330

325331
meta = {
326-
# Add default meta information
332+
# Add default meta information.
327333
platforms = go.meta.platforms or lib.platforms.all;
328334
} // meta;
329335
}

0 commit comments

Comments
 (0)