Commit Graph

85 Commits

Author SHA1 Message Date
Matt Sturgeon
cea24fefd1 buildGoModule: supported structuredAttrs with subPackages (#519903) 2026-07-04 01:49:49 +00:00
Ross Smyth
f52e868a2e buildGoModule: supported structuredAttrs with subPackages 2026-05-13 16:52:04 -04:00
Stefan Frijters
a05078ee87 buildGoModule: expand excludedPackages for structuredAttrs 2026-03-16 00:49:45 +01:00
Stefan Frijters
83549e3ad2 buildGoModule: fix GOFLAGS for structuredAttrs 2025-12-14 12:52:50 +01:00
nixpkgs-ci[bot]
39f48e45c5 Merge staging-next into staging 2025-10-31 18:07:11 +00:00
Pol Dellaiera
474f62e914 build-support/go: clarify vendorHash
So programs doesn't need dependencies (e.g., issue2md), that
doesn't mean the dependencies are in the source tree.
2025-10-31 13:13:25 +01:00
Luna Nova
08aadbf8d4 go: position independent executables by default
Followup to setting --enable-default-pie for our gcc,
we teach go to build PIE by default when supported.
2025-10-07 20:27:45 -07:00
Luna Nova
97a43a6db4 go: teach internal linker to use correct ELF interpreter
Teaches go's internal linker to use the GO_LDSO env var as the path for the dynamic linker, instead of defaulting to an FHS /lib path.
GO_LDSO is automatically set to the appropriate value by checking $NIX_CC/nix-support/dynamic-linker
External linking is set as the default for cross compile situations
where CGO is supported.
Teaching go to correctly handle cross
in the internal linker is hard, and our system linker already knows
how to find the right ELF interpreter.
For cross situations where CGO is not supported we assume either non-ELF
binaries or static binaries will be produced.
2025-10-07 17:32:25 -07:00
Paul Meyer
c68db54e93 buildGoModule: remove unused argument defaults (#441838) 2025-10-06 13:59:00 +00:00
nixpkgs-ci[bot]
d158bb26b3 Merge master into staging-next 2025-09-21 18:05:23 +00:00
Yueh-Shun Li
3c9b0f85a4 buildGoModule: remove compatibility layer for directly specified CGO_ENABLED 2025-09-11 02:15:29 +08:00
Yueh-Shun Li
de854a65f2 buildGoModule: remove unused argument defaults 2025-09-11 01:47:31 +08:00
Yueh-Shun Li
1fa17f4fa3 buildGoModule: reference allowGoReference from finalAttrs 2025-09-11 01:35:52 +08:00
nixpkgs-ci[bot]
e849ba637a Merge staging-next into staging 2025-08-29 00:17:30 +00:00
Yueh-Shun Li
8c54246b3d buildGoModule: warn for passthru.overrideModAttrs lost after overriding 2025-08-29 03:10:57 +08:00
Paul Meyer
cf4e81e3bc buildGoModule: add buildTestBinaries option, add tests (#427334) 2025-08-12 10:14:14 +02:00
Wolfgang Walther
5a0711127c treewide: run nixfmt 1.0.0 2025-07-24 13:55:40 +02:00
Paul Meyer
21c8967f1c buildGoModule: add buildTestBinaries option
Signed-off-by: Paul Meyer <katexochen0@gmail.com>
2025-07-21 20:18:56 +02:00
Tristan Ross
902d4f604f buildGoModule: add goSum attribute to make goModules rebuild (#399532) 2025-04-22 11:11:44 -07:00
Pol Dellaiera
fa65f09a8f build-support/go: reformat with nixfmt-rfc-style 2025-03-16 09:26:36 +01:00
Pol Dellaiera
362e56fc56 build-support/go: remove unused parameters 2025-03-16 09:26:15 +01:00
Pol Dellaiera
db40ae162d build-support/go: replace git with gitMinimal 2025-03-16 09:25:15 +01:00
Pol Dellaiera
8646ca52f3 build-support/go: support finalAttrs through lib.extendMkDerivation 2025-03-16 09:22:41 +01:00
K900
936f4e016d Merge remote-tracking branch 'origin/staging-next' into staging 2025-01-02 19:21:56 +03:00
Paul Meyer
524a505874 buildGoModule: remove some unnecessary quotes (#370005) 2025-01-02 08:56:45 +01:00
Gabriel Nützi
3b0d5f365e buildGoModule: remove some unnecessary quotes 2025-01-01 18:27:45 +01:00
K900
7661b4ac55 Merge remote-tracking branch 'origin/staging-next' into staging 2024-12-19 12:47:54 +03:00
github-actions[bot]
6a83ff87ac Merge master into staging-next 2024-12-19 00:15:19 +00:00
Yueh-Shun Li
3b1ec755ca buildGoModule: instruct users to specify CGO_ENABLED as env.CGO_ENABLED
Tell users to specify environment variables via `env`.

Rename the `var-go-CGO_ENABLED` documentation title
from `CGO_ENABLED` to `env.CGO_ENABLED`
and move the paragraphs under the `ssec-go-environment`.
2024-12-18 23:20:17 +08:00
Yueh-Shun Li
44876c6004 buildGoModule: pass environment variables with the env attribute
This help Go modules support __structuredAttrs = true.

This commit doesn't touch GOFLAGS, which will be handled in subequent
changes.
2024-12-18 23:16:41 +08:00
Yueh-Shun Li
22c6ae979e buildGoModule: Use environment variable GOOS and GOARCH directly 2024-11-29 11:55:37 +08:00
Yueh-Shun Li
b9efad374e buildGoModule: handle ldflags and tags __structuredAttrs-agnostically 2024-11-29 11:55:36 +08:00
Martin Weinelt
9b1b10369d Merge remote-tracking branch 'origin/staging-next' into staging
Conflicts:
- pkgs/development/python-modules/pytest-codspeed/default.nix
2024-11-28 17:11:16 +01:00
Yueh-Shun Li
7542b942a4 buildGoModule: no longer filter out vendorSha256 2024-11-28 00:11:33 +08:00
github-actions[bot]
40a26e9ba0 Merge staging-next into staging 2024-11-19 18:04:59 +00:00
Paul Meyer
41d7136253 buildGoModule: remove goPackagePath warning
As buildGoPackage was removed, it is unlikely for attributes of
buildGoModule to get mixed up with those of buildGoPackage.

Signed-off-by: Paul Meyer <49727155+katexochen@users.noreply.github.com>
2024-11-18 14:36:08 +01:00
Paul Meyer
36223da9c1 buildGoModule: remove buildFlags/buildFlagsArray
Signed-off-by: Paul Meyer <49727155+katexochen@users.noreply.github.com>
2024-11-08 09:16:33 +01:00
Jörg Thalheim
a808f823bb Merge branch 'master' into docs/improve-go-builder 2024-10-12 13:16:51 +02:00
Gabriel Nützi
9a6d7cc9f7 module.nix aktualisieren
Co-authored-by: Wael Nasreddine <wael.nasreddine@gmail.com>
2024-10-11 12:00:13 +02:00
Yueh-Shun Li
e31ace5cd4 buildGoModule: use lib.toExtension
Use toExtension from Nixpkgs library instead of the one defined locally.
2024-09-14 21:47:59 +08:00
Gabriel Nützi
ba2b91866b chore: typos and comment fixups in Go build-support function 2024-09-13 13:26:51 +02:00
K900
23b4832da0 Merge remote-tracking branch 'origin/master' into staging-next 2024-09-04 08:53:48 +03:00
Sandro Jäckel
bc12ef1bf0 buildGoModule: be nicer when overrideAttrs clears passthru
Before an overlay in the form of:

package.overrideAttrs (old: {
  passthru = {};
})

would fail evaluation like:

       error: attribute 'overrideModAttrs' missing
       at /nix/store/afwc3m1sm49qq57xjv2hmd7iy4x0j33h-source/pkgs/build-support/go/module.nix:179:20:
          178|     outputHashAlgo = if finalAttrs.vendorHash == "" then "sha256" else null;
          179|   }).overrideAttrs finalAttrs.passthru.overrideModAttrs;
             |                    ^
          180|

Now instead we take the fallback default.
2024-09-02 17:53:36 +02:00
Tim Cuthbertson
911aa1440f treewide: support NIX_SSL_CERT_FILE as an impureEnvVar
This envvar is also added to lib.proxyImpureEnvVars since it's
typically required for https proxies.

This change also updates fetchgit and go module fetching to use this
envvar. NIX_GIT_SSL_CAINFO is still supported for backwards
compatibility in fetchgit.
2024-08-23 21:34:22 +10:00
Yueh-Shun Li
eed069a5bc buildGoModule: fix overrideAttrs overriding
Fix overriding of vendorHash and various attributes via the fixed point
attribute support of stdenv.mkDerivation.

Pass as derivation attributes
goModules, modRoot, vendorHash, deleteVendor, and proxyVendor.

Move goModules and vendorHash out of passthru.

Co-authored-by: Doron Behar <doron.behar@gmail.com>
2024-08-11 13:38:11 +08:00
Yueh-Shun Li
010277de84 buildGoModule: respect user-specified passthru
Prioritize user-specified passthru arguments over those added by
buildGoModule.
2024-07-29 06:47:12 +08:00
Wael Nasreddine
0505253a30 Merge pull request #303217 from deshaw/buildGoModule-setSourceRoot
buildGoModule: propagate setSourceRoot
2024-07-09 15:10:02 -07:00
Yueh-Shun Li
26baea8388 buildGoModule: don't pass buildFlagsArray as file
Store buildFlagsArray as Bash global array variable instead of
creating/sourcing a file containing its declaration.

buildFlagsArray is short enough, and it is not assigned in a sub-shell.
There's no reason to pass it as a file. Storing it as a variable makes
the build more efficient.
2024-06-01 23:29:41 +00:00
Weijia Wang
b4617eb071 Merge branch 'staging-next' into staging 2024-05-03 19:03:51 +02:00
Weijia Wang
a6742256e2 Merge pull request #279391 from katexochen/buildGoModule/deprecate-buildflags
buildGoModule: announce removal of `buildFlags` and `buildFlagsArray`
2024-05-02 12:58:35 +02:00