From 89b9a4d9af33a69f26dd9c53042e8d1d16f3fb64 Mon Sep 17 00:00:00 2001 From: Laurent Arnoud Date: Wed, 18 Feb 2026 10:36:49 +0000 Subject: [PATCH] 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 --- pkgs/applications/networking/cluster/terraform/default.nix | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pkgs/applications/networking/cluster/terraform/default.nix b/pkgs/applications/networking/cluster/terraform/default.nix index 2541fb2b871e..2a05f192c7f8 100644 --- a/pkgs/applications/networking/cluster/terraform/default.nix +++ b/pkgs/applications/networking/cluster/terraform/default.nix @@ -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"