diff --git a/pkgs/build-support/go/module.nix b/pkgs/build-support/go/module.nix index 30542b1d16c6..ce699c213454 100644 --- a/pkgs/build-support/go/module.nix +++ b/pkgs/build-support/go/module.nix @@ -253,6 +253,9 @@ lib.extendMkDerivation { if [ -f "$NIX_CC_FOR_TARGET/nix-support/dynamic-linker" ]; then export GO_LDSO=$(cat $NIX_CC_FOR_TARGET/nix-support/dynamic-linker) fi + if [ "$CGO_ENABLED" = "0" ]; then + export GOFLAGS="-buildmode=exe $GOFLAGS" + fi cd "$modRoot" '' + lib.optionalString (finalAttrs.vendorHash != null) '' diff --git a/pkgs/development/compilers/go/tests.nix b/pkgs/development/compilers/go/tests.nix index e8756419fcfb..3eeaa8b53262 100644 --- a/pkgs/development/compilers/go/tests.nix +++ b/pkgs/development/compilers/go/tests.nix @@ -15,7 +15,7 @@ let skopeo' = skopeo.override { buildGoModule = buildGoModule; }; athens' = athens.override { buildGoModule = buildGoModule; }; expectedCgoEnabledType = "DYN"; - expectedCgoDisabledType = "DYN"; + expectedCgoDisabledType = "EXE"; in { skopeo = testers.testVersion { package = skopeo'; };