|
1 | 1 | { go, cacert, git, lib, stdenv }: |
2 | 2 |
|
3 | 3 | { name ? "${args'.pname}-${args'.version}" |
| 4 | + # The source used to build the derivation. |
4 | 5 | , src |
| 6 | + # Native build inputs used for the derivation. |
5 | 7 | , nativeBuildInputs ? [ ] |
6 | 8 | , passthru ? { } |
7 | 9 | , patches ? [ ] |
8 | 10 |
|
9 | | - # A function to override the goModules derivation |
| 11 | + # A function to override the `goModules` derivation. |
10 | 12 | , overrideModAttrs ? (finalAttrs: previousAttrs: { }) |
11 | 13 |
|
12 | | - # path to go.mod and go.sum directory |
| 14 | + # Directory to the `go.mod` and `go.sum` relative to the `src`. |
13 | 15 | , modRoot ? "./" |
14 | 16 |
|
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. |
19 | 20 | , vendorHash ? throw ( |
20 | 21 | if args'?vendorSha256 then |
21 | 22 | "buildGoModule: Expect vendorHash instead of vendorSha256" |
22 | 23 | else |
23 | 24 | "buildGoModule: vendorHash is missing" |
24 | 25 | ) |
| 26 | + |
25 | 27 | # Whether to delete the vendor folder supplied with the source. |
26 | 28 | , deleteVendor ? false |
| 29 | + |
27 | 30 | # Whether to fetch (go mod download) and proxy the vendor directory. |
28 | 31 | # This is useful if your code depends on c code and go mod tidy does not |
29 | 32 | # include the needed sources to build or if any dependency has case-insensitive |
30 | 33 | # conflicts which will produce platform dependant `vendorHash` checksums. |
31 | 34 | , proxyVendor ? false |
32 | 35 |
|
33 | | - # We want parallel builds by default |
| 36 | + # We want parallel builds by default. |
34 | 37 | , enableParallelBuilding ? true |
35 | 38 |
|
36 | 39 | # Do not enable this without good reason |
37 | | - # IE: programs coupled with the compiler |
| 40 | + # IE: programs coupled with the compiler. |
38 | 41 | , allowGoReference ? false |
39 | 42 |
|
| 43 | + # Go env. variable to enable CGO. |
40 | 44 | , CGO_ENABLED ? go.CGO_ENABLED |
41 | 45 |
|
| 46 | + # Meta data for the final derivation. |
42 | 47 | , meta ? { } |
43 | 48 |
|
44 | | - # Not needed with buildGoModule |
| 49 | + # Not needed with `buildGoModule`. |
45 | 50 | , goPackagePath ? "" |
46 | 51 |
|
| 52 | + # Go linker flags. |
47 | 53 | , ldflags ? [ ] |
48 | | - |
| 54 | + # Go build flags. |
49 | 55 | , GOFLAGS ? [ ] |
50 | 56 |
|
51 | | - # needed for buildFlags{,Array} warning |
52 | | -, buildFlags ? "" |
53 | | -, buildFlagsArray ? "" |
| 57 | + # Needed for buildFlags{,Array} warning |
| 58 | +, buildFlags ? "" # deprecated |
| 59 | +, buildFlagsArray ? "" # deprecated |
54 | 60 |
|
55 | 61 | , ... |
56 | 62 | }@args': |
|
79 | 85 | inherit (go) GOOS GOARCH; |
80 | 86 | inherit GO111MODULE GOTOOLCHAIN; |
81 | 87 |
|
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 |
83 | 89 | # argue it's not ideal. Changing it may break vendor hashes in Nixpkgs and |
84 | 90 | # out in the wild. In anycase, it's documented in: |
85 | | - # doc/languages-frameworks/go.section.md |
| 91 | + # doc/languages-frameworks/go.section.md. |
86 | 92 | prePatch = finalAttrs.prePatch or ""; |
87 | 93 | patches = finalAttrs.patches or [ ]; |
88 | 94 | patchFlags = finalAttrs.patchFlags or [ ]; |
|
160 | 166 |
|
161 | 167 | outputHashMode = "recursive"; |
162 | 168 | 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. |
165 | 171 | outputHashAlgo = if finalAttrs.vendorHash == "" then "sha256" else null; |
166 | 172 | # in case an overlay clears passthru by accident, don't fail evaluation |
167 | 173 | }).overrideAttrs (finalAttrs.passthru.overrideModAttrs or overrideModAttrs); |
|
323 | 329 | } // passthru; |
324 | 330 |
|
325 | 331 | meta = { |
326 | | - # Add default meta information |
| 332 | + # Add default meta information. |
327 | 333 | platforms = go.meta.platforms or lib.platforms.all; |
328 | 334 | } // meta; |
329 | 335 | } |
|
0 commit comments