diff options
Diffstat (limited to 'pkgs')
-rw-r--r-- | pkgs/applications/networking/cluster/terraform-providers/default.nix | 15 | ||||
-rw-r--r-- | pkgs/applications/networking/cluster/terraform/default.nix | 48 |
2 files changed, 18 insertions, 45 deletions
diff --git a/pkgs/applications/networking/cluster/terraform-providers/default.nix b/pkgs/applications/networking/cluster/terraform-providers/default.nix index 47bd402a224..8690e65be88 100644 --- a/pkgs/applications/networking/cluster/terraform-providers/default.nix +++ b/pkgs/applications/networking/cluster/terraform-providers/default.nix @@ -19,7 +19,8 @@ let , vendorSha256 ? throw "vendorSha256 missing: please use `buildGoModule`" /* added 2022/01 */ , deleteVendor ? false , proxyVendor ? false - , provider-source-address + , # Looks like "registry.terraform.io/vancluever/acme" + provider-source-address }@attrs: buildGoModule { pname = repo; @@ -34,9 +35,15 @@ let inherit owner repo rev sha256; }; - # Terraform allow checking the provider versions, but this breaks - # if the versions are not provided via file paths. - postBuild = "mv $NIX_BUILD_TOP/go/bin/${repo}{,_v${version}}"; + # Move the provider to libexec + postInstall = '' + dir=$out/libexec/terraform-providers/${provider-source-address}/${version}/''${GOOS}_''${GOARCH} + mkdir -p "$dir" + mv $out/bin/* "$dir/terraform-provider-$(basename ${provider-source-address})_${version}" + rmdir $out/bin + ''; + + # Keep the attributes around for later consumption passthru = attrs; }; diff --git a/pkgs/applications/networking/cluster/terraform/default.nix b/pkgs/applications/networking/cluster/terraform/default.nix index bc179ea55eb..a5e92bedef6 100644 --- a/pkgs/applications/networking/cluster/terraform/default.nix +++ b/pkgs/applications/networking/cluster/terraform/default.nix @@ -1,5 +1,6 @@ { stdenv , lib +, buildEnv , buildGoModule , fetchFromGitHub , makeWrapper @@ -62,9 +63,9 @@ let babariviere kalbasit marsam + maxeaubrey timstott zimbatm - maxeaubrey zowoq ]; }; @@ -76,39 +77,6 @@ let let actualPlugins = plugins terraform.plugins; - # Make providers available in Terraform 0.13 and 0.12 search paths. - pluginDir = lib.concatMapStrings - (pl: - let - 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/${pname}_v${version} "$@" - ''; - in - '' - 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/${pname}_v${version} - - cp ${shim} "$TF_0_12_PROVIDER_PATH" - chmod +x "$TF_0_12_PROVIDER_PATH" - '' - ) - actualPlugins; - # Wrap PATH of plugins propagatedBuildInputs, plugins may have runtime dependencies on external binaries wrapperInputs = lib.unique (lib.flatten (lib.catAttrs "propagatedBuildInputs" @@ -134,18 +102,16 @@ let terraform.overrideAttrs (orig: { passthru = orig.passthru // passthru; }) else - lib.appendToName "with-plugins" (stdenv.mkDerivation { + lib.appendToName "with-plugins" (buildEnv { inherit (terraform) name meta; + paths = actualPlugins; nativeBuildInputs = [ makeWrapper ]; - - buildCommand = pluginDir + '' - mkdir -p $out/bin/ + postBuild = '' + mkdir -p $out/bin makeWrapper "${terraform}/bin/terraform" "$out/bin/terraform" \ - --set NIX_TERRAFORM_PLUGIN_DIR $out/plugins \ + --set NIX_TERRAFORM_PLUGIN_DIR $out/libexec/terraform-providers \ --prefix PATH : "${lib.makeBinPath wrapperInputs}" ''; - - inherit passthru; }); in withPlugins (_: [ ]); |