diff --git a/pkgs/development/go-modules/generic/default.nix b/pkgs/development/go-modules/generic/default.nix index 4dff2d82848d..d0dc55376faa 100644 --- a/pkgs/development/go-modules/generic/default.nix +++ b/pkgs/development/go-modules/generic/default.nix @@ -180,12 +180,22 @@ let exclude+='\)' buildGoDir() { - local d; local cmd; - cmd="$1" - d="$2" + local cmd="$1" dir="$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 $buildFlags "''${buildFlagsArray[@]}" ''${tags:+-tags=${lib.concatStringsSep "," tags}} ''${ldflags:+-ldflags="$ldflags"} -v -p $NIX_BUILD_CORES $d 2>&1)"; then + if ! OUT="$(go $cmd "''${flags[@]}" $dir 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 @@ -243,7 +253,7 @@ let runHook preCheck for pkg in $(getGoDirs test); do - buildGoDir test $checkFlags "$pkg" + buildGoDir test "$pkg" done runHook postCheck diff --git a/pkgs/development/go-packages/generic/default.nix b/pkgs/development/go-packages/generic/default.nix index 0559f7f07a7c..643c1955d2b0 100644 --- a/pkgs/development/go-packages/generic/default.nix +++ b/pkgs/development/go-packages/generic/default.nix @@ -160,12 +160,22 @@ let exclude+='\)' buildGoDir() { - local d; local cmd; - cmd="$1" - d="$2" + local cmd="$1" dir="$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 $buildFlags "''${buildFlagsArray[@]}" ''${tags:+-tags=${lib.concatStringsSep "," tags}} ''${ldflags:+-ldflags="$ldflags"} -v -p $NIX_BUILD_CORES $d 2>&1)"; then + if ! OUT="$(go $cmd "''${flags[@]}" $dir 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 @@ -225,7 +235,7 @@ let runHook preCheck for pkg in $(getGoDirs test); do - buildGoDir test $checkFlags "$pkg" + buildGoDir test "$pkg" done runHook postCheck