terraform: set CGO_ENABLED based on platform in env

- Linux: CGO_ENABLED=0 for static linking (avoids LTO plugin issues)
- Darwin: CGO_ENABLED=1 to avoid DNS resolution issues

This fixes the build by using env.CGO_ENABLED instead of a direct
derivation argument, which is required by buildGoModule in modern Nix.

See: https://github.com/hashicorp/terraform/blob/main/BUILDING.md
This commit is contained in:
Laurent Arnoud
2026-02-18 10:36:49 +00:00
parent c1aeab53ef
commit 89b9a4d9af
@@ -39,6 +39,12 @@ let
inherit hash;
};
# Set CGO_ENABLED based on platform:
# - Linux: CGO_ENABLED=0 for static linking (avoids LTO plugin issues)
# - Darwin: CGO_ENABLED=1 to avoid DNS resolution issues
# See: https://github.com/hashicorp/terraform/blob/main/BUILDING.md
env.CGO_ENABLED = if stdenv.hostPlatform.isDarwin then "1" else "0";
ldflags = [
"-s"
"-w"