buildGoModule: access ldflags and tags __structuredAttrs-agnostically (#360037)

This commit is contained in:
Yueh-Shun Li
2024-12-19 01:21:27 +08:00
committed by GitHub
+3 -3
View File
@@ -222,8 +222,8 @@ in
local cmd="$1" dir="$2"
declare -a flags
flags+=(''${tags:+-tags=''${tags// /,}})
flags+=(''${ldflags:+-ldflags="$ldflags"})
flags+=(''${tags:+-tags=$(concatStringsSep "," tags)})
flags+=(''${ldflags:+-ldflags="''${ldflags[*]}"})
flags+=("-p" "$NIX_BUILD_CORES")
if (( "''${NIX_DEBUG:-0}" >= 1 )); then
flags+=(-x)
@@ -267,7 +267,7 @@ in
'' + lib.optionalString (stdenv.hostPlatform != stdenv.buildPlatform) ''
# normalize cross-compiled builds w.r.t. native builds
(
dir=$GOPATH/bin/${go.GOOS}_${go.GOARCH}
dir=$GOPATH/bin/''${GOOS}_''${GOARCH}
if [[ -n "$(shopt -s nullglob; echo $dir/*)" ]]; then
mv $dir/* $dir/..
fi