Merge pull request #276685 from katexochen/buildGoModule/buildid

buildGoModule: always set `-buildid=` as ldflag
This commit is contained in:
Jörg Thalheim 2024-01-14 14:13:16 +01:00 committed by GitHub
commit a292058564
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 25 additions and 14 deletions

View File

@ -13,7 +13,7 @@ buildGoModule rec {
CGO_ENABLED = 0;
ldflags = [ "-X github.com/mzz2017/gg/cmd.Version=${version}" "-s" "-w" "-buildid=" ];
ldflags = [ "-X github.com/mzz2017/gg/cmd.Version=${version}" "-s" "-w" ];
vendorHash = "sha256-fnM4ycqDyruCdCA1Cr4Ki48xeQiTG4l5dLVuAafEm14=";
subPackages = [ "." ];

View File

@ -19,7 +19,7 @@ buildGoModule rec {
nativeBuildInputs = [ makeWrapper ];
ldflags = [ "-s" "-w" "-buildid=" "-X github.com/sigstore/gitsign/pkg/version.gitVersion=${version}" ];
ldflags = [ "-s" "-w" "-X github.com/sigstore/gitsign/pkg/version.gitVersion=${version}" ];
preCheck = ''
# test all paths

View File

@ -39,6 +39,8 @@
# Not needed with buildGoModule
, goPackagePath ? ""
, ldflags ? [ ]
# needed for buildFlags{,Array} warning
, buildFlags ? ""
, buildFlagsArray ? ""
@ -154,6 +156,9 @@ let
GOFLAGS = lib.optionals (!proxyVendor) [ "-mod=vendor" ] ++ lib.optionals (!allowGoReference) [ "-trimpath" ];
inherit CGO_ENABLED enableParallelBuilding GO111MODULE GOTOOLCHAIN;
# If not set to an explicit value, set the buildid empty for reproducibility.
ldflags = ldflags ++ lib.optionals (!lib.any (lib.hasPrefix "-buildid=") ldflags) [ "-buildid=" ];
configurePhase = args.configurePhase or (''
runHook preConfigure
@ -301,4 +306,5 @@ in
lib.warnIf (args' ? vendorSha256) "`vendorSha256` is deprecated. Use `vendorHash` instead"
lib.warnIf (buildFlags != "" || buildFlagsArray != "")
"Use the `ldflags` and/or `tags` attributes instead of `buildFlags`/`buildFlagsArray`"
lib.warnIf (builtins.elem "-buildid=" ldflags) "`-buildid=` is set by default as ldflag by buildGoModule"
package

View File

@ -37,6 +37,8 @@
, CGO_ENABLED ? go.CGO_ENABLED
, ldflags ? [ ]
# needed for buildFlags{,Array} warning
, buildFlags ? ""
, buildFlagsArray ? ""
@ -91,6 +93,9 @@ let
GOARM = toString (lib.intersectLists [(stdenv.hostPlatform.parsed.cpu.version or "")] ["5" "6" "7"]);
# If not set to an explicit value, set the buildid empty for reproducibility.
ldflags = ldflags ++ lib.optionals (!lib.any (lib.hasPrefix "-buildid=") ldflags) [ "-buildid=" ];
configurePhase = args.configurePhase or (''
runHook preConfigure
@ -280,4 +285,5 @@ let
in
lib.warnIf (buildFlags != "" || buildFlagsArray != "")
"Use the `ldflags` and/or `tags` attributes instead of `buildFlags`/`buildFlagsArray`"
lib.warnIf (builtins.elem "-buildid=" ldflags) "`-buildid=` is set by default as ldflag by buildGoModule"
package

View File

@ -18,7 +18,7 @@ buildGoModule rec {
vendorHash = "sha256-8+PdkanodNZW/xeFf+tDm3Ej7DRSpBBtiT/CqjnWthw=";
CGO_ENABLED = "0";
ldflags = [ "-s" "-w" "-buildid=" "-X github.com/gomods/athens/pkg/build.version=${version}" ];
ldflags = [ "-s" "-w" "-X github.com/gomods/athens/pkg/build.version=${version}" ];
subPackages = [ "cmd/proxy" ];

View File

@ -16,7 +16,7 @@ buildGo121Module rec {
vendorHash = "sha256-RsjUPLe8omoN+XGyNhHDxzNfZR7VVTkh/f/On1oCRqM=";
CGO_ENABLED = "0";
ldflags = [ "-s" "-w" "-buildid=" "-X main.version=${version}" ];
ldflags = [ "-s" "-w" "-X main.version=${version}" ];
flags = [ "-trimpath" ];
meta = with lib; {

View File

@ -21,7 +21,11 @@ buildGoModule rec {
CGO_ENABLED = "0";
ldflags = "-s -w -X main.version=v${version}";
ldflags = [
"-s"
"-w"
"-X main.version=v${version}"
];
checkFlags = [
# Requires network access (Error: module lookup disabled by GOPROXY=off).

View File

@ -20,7 +20,7 @@ buildGoModule rec {
CGO_ENABLED = 0;
GOFLAGS = [ "-trimpath" ];
ldflags = [ "-buildid=" "-w" ];
ldflags = [ "-w" ];
doCheck = false;

View File

@ -17,7 +17,7 @@ buildGoModule rec {
vendorHash = "sha256-zeiOcn33PnyoseYb0wynkn7MfGp3rHEYBStY98C6aR8=";
ldflags = [
"-w" "-s" "-buildid="
"-w" "-s"
"-X github.com/xjasonlyu/tun2socks/v2/internal/version.Version=v${version}"
"-X github.com/xjasonlyu/tun2socks/v2/internal/version.GitCommit=v${version}"
];

View File

@ -19,7 +19,7 @@ buildGoModule rec {
# https://github.com/Mic92/nix-update/pull/95
vendorHash = "sha256-ZBvHu4BEmQi6PQwRHuVwx/6X4gBqlRR44OktKRBGcs4=";
ldflags = [ "-s" "-w" "-buildid=" ];
ldflags = [ "-s" "-w" ];
subPackages = [ "main" ];

View File

@ -26,7 +26,7 @@ buildGoModule rec {
doCheck = false;
ldflags = [ "-s" "-w" "-buildid=" ];
ldflags = [ "-s" "-w" ];
subPackages = [ "main" ];
installPhase = ''

View File

@ -27,7 +27,6 @@ buildGoModule rec {
ldflags = [
"-s"
"-w"
"-buildid="
"-X sigs.k8s.io/release-utils/version.gitVersion=${version}"
];

View File

@ -23,10 +23,6 @@ buildGoModule rec {
vendorHash = "sha256-AXMMpzXEhdKSGeVg/KK2NEgalxIXP6DUTcoxOQVqow4=";
ldflags = [
"-buildid="
];
nativeBuildInputs = lib.optionals hsmSupport [
pkg-config
];