diff --git a/pkgs/development/go-modules/generic/default.nix b/pkgs/development/go-modules/generic/default.nix index d0dc55376fa..4dff2d82848 100644 --- a/pkgs/development/go-modules/generic/default.nix +++ b/pkgs/development/go-modules/generic/default.nix @@ -180,22 +180,12 @@ let exclude+='\)' buildGoDir() { - local cmd="$1" dir="$2" - + local d; local cmd; + cmd="$1" + d="$2" . $TMPDIR/buildFlagsArray - - declare -a flags - flags+=($buildFlags "''${buildFlagsArray[@]}") - flags+=(''${tags:+-tags=${lib.concatStringsSep "," tags}}) - flags+=(''${ldflags:+-ldflags="$ldflags"}) - flags+=("-v" "-p" "$NIX_BUILD_CORES") - - if [ "$cmd" = "test" ]; then - flags+=($checkFlags) - fi - local OUT - if ! OUT="$(go $cmd "''${flags[@]}" $dir 2>&1)"; then + if ! OUT="$(go $cmd $buildFlags "''${buildFlagsArray[@]}" ''${tags:+-tags=${lib.concatStringsSep "," tags}} ''${ldflags:+-ldflags="$ldflags"} -v -p $NIX_BUILD_CORES $d 2>&1)"; then if ! echo "$OUT" | grep -qE '(no( buildable| non-test)?|build constraints exclude all) Go (source )?files'; then echo "$OUT" >&2 return 1 @@ -253,7 +243,7 @@ let runHook preCheck for pkg in $(getGoDirs test); do - buildGoDir test "$pkg" + buildGoDir test $checkFlags "$pkg" done runHook postCheck diff --git a/pkgs/development/go-packages/generic/default.nix b/pkgs/development/go-packages/generic/default.nix index 643c1955d2b..0559f7f07a7 100644 --- a/pkgs/development/go-packages/generic/default.nix +++ b/pkgs/development/go-packages/generic/default.nix @@ -160,22 +160,12 @@ let exclude+='\)' buildGoDir() { - local cmd="$1" dir="$2" - + local d; local cmd; + cmd="$1" + d="$2" . $TMPDIR/buildFlagsArray - - declare -a flags - flags+=($buildFlags "''${buildFlagsArray[@]}") - flags+=(''${tags:+-tags=${lib.concatStringsSep "," tags}}) - flags+=(''${ldflags:+-ldflags="$ldflags"}) - flags+=("-v" "-p" "$NIX_BUILD_CORES") - - if [ "$cmd" = "test" ]; then - flags+=($checkFlags) - fi - local OUT - if ! OUT="$(go $cmd "''${flags[@]}" $dir 2>&1)"; then + if ! OUT="$(go $cmd $buildFlags "''${buildFlagsArray[@]}" ''${tags:+-tags=${lib.concatStringsSep "," tags}} ''${ldflags:+-ldflags="$ldflags"} -v -p $NIX_BUILD_CORES $d 2>&1)"; then if ! echo "$OUT" | grep -qE '(no( buildable| non-test)?|build constraints exclude all) Go (source )?files'; then echo "$OUT" >&2 return 1 @@ -235,7 +225,7 @@ let runHook preCheck for pkg in $(getGoDirs test); do - buildGoDir test "$pkg" + buildGoDir test $checkFlags "$pkg" done runHook postCheck