diff options
author | zimbatm <zimbatm@zimbatm.com> | 2020-10-09 12:44:23 +0200 |
---|---|---|
committer | zimbatm <zimbatm@zimbatm.com> | 2020-10-09 16:55:30 +0200 |
commit | c79ff8ddca6a18fc04873221ed2544c41993cd2c (patch) | |
tree | 22f41a43f19ef67cec700b457376080d32869249 /pkgs/applications/networking/cluster/terraform | |
parent | 3f49e5ba03db71ca54deac6dfcf73b8e25356b76 (diff) |
terraform: fix withPlugins
Move the providerSourceAddress fallback to the terraform.withPlugins
function. Since plugins can be arbitrary derivations, there is no
guarantee that this attribute will be exposed.
While doing that I also cleaned the toDrv function to only pass
attributes to the builder which are required by the build.
The Terraform 0.13 fallback slug has changed from
`nixpkgs/<provider-owner>/<provider-name>` to `nixpkgs/<provider-name>`
as the owner is also not always available. As a nixpkgs user, all I know
is that the provider is in nixpkgs and his name, the owner information
is not necessarily easy to get by.
Diffstat (limited to 'pkgs/applications/networking/cluster/terraform')
-rw-r--r-- | pkgs/applications/networking/cluster/terraform/default.nix | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/pkgs/applications/networking/cluster/terraform/default.nix b/pkgs/applications/networking/cluster/terraform/default.nix index 298d80bcbaa1..6153eaa145c9 100644 --- a/pkgs/applications/networking/cluster/terraform/default.nix +++ b/pkgs/applications/networking/cluster/terraform/default.nix @@ -62,21 +62,27 @@ let # Make providers available in Terraform 0.13 and 0.12 search paths. pluginDir = lib.concatMapStrings (pl: let - inherit (pl) repo version GOOS GOARCH; - inherit (pl.passthru) providerSourceAddress; + inherit (pl) version GOOS GOARCH; + + pname = pl.pname or (throw "${pl.name} is missing a pname attribute"); + + # This is just the name, without the terraform-provider- prefix + plugin_name = lib.removePrefix "terraform-provider-" pname; + + slug = pl.passthru.provider-source-address or "registry.terraform.io/nixpkgs/${plugin_name}"; shim = writeText "shim" '' #!${runtimeShell} - exec ${pl}/bin/${repo}_v${version} \$@ + exec ${pl}/bin/${pname}_v${version} "$@" ''; in '' - TF_0_13_PROVIDER_PATH=$out/plugins/${providerSourceAddress}/${version}/${GOOS}_${GOARCH}/${repo}_v${version} + TF_0_13_PROVIDER_PATH=$out/plugins/${slug}/${version}/${GOOS}_${GOARCH}/${pname}_v${version} mkdir -p "$(dirname $TF_0_13_PROVIDER_PATH)" cp ${shim} "$TF_0_13_PROVIDER_PATH" chmod +x "$TF_0_13_PROVIDER_PATH" - TF_0_12_PROVIDER_PATH=$out/plugins/${repo}_v${version} + TF_0_12_PROVIDER_PATH=$out/plugins/${pname}_v${version} cp ${shim} "$TF_0_12_PROVIDER_PATH" chmod +x "$TF_0_12_PROVIDER_PATH" |