terraform: noop 0.10 plugins mechanism when unused
This commit is contained in:
parent
b291ead4aa
commit
11753b3273
@ -40,24 +40,34 @@ let
|
|||||||
|
|
||||||
pluggable = terraform:
|
pluggable = terraform:
|
||||||
let
|
let
|
||||||
withPlugins = plugins: stdenv.mkDerivation {
|
withPlugins = plugins:
|
||||||
name = "${terraform.name}-with-plugins";
|
let
|
||||||
buildInputs = [ makeWrapper ];
|
actualPlugins = plugins terraform.plugins;
|
||||||
|
|
||||||
buildCommand = ''
|
|
||||||
mkdir -p $out/bin/
|
|
||||||
makeWrapper "${terraform.bin}/bin/terraform" "$out/bin/terraform" \
|
|
||||||
--set NIX_TERRAFORM_PLUGIN_DIR "${buildEnv { name = "tf-plugin-env"; paths = plugins terraform.plugins; }}/bin"
|
|
||||||
'';
|
|
||||||
|
|
||||||
passthru = {
|
passthru = {
|
||||||
withPlugins = newplugins: withPlugins (x: newplugins x ++ plugins x);
|
withPlugins = newplugins: withPlugins (x: newplugins x ++ actualPlugins);
|
||||||
|
|
||||||
# Ouch
|
# Ouch
|
||||||
overrideDerivation = f: (pluggable (terraform.overrideDerivation f)).withPlugins plugins;
|
overrideDerivation = f: (pluggable (terraform.overrideDerivation f)).withPlugins plugins;
|
||||||
overrideAttrs = f: (pluggable (terraform.overrideAttrs f)).withPlugins plugins;
|
overrideAttrs = f: (pluggable (terraform.overrideAttrs f)).withPlugins plugins;
|
||||||
override = x: (pluggable (terraform.override x)).withPlugins plugins;
|
override = x: (pluggable (terraform.override x)).withPlugins plugins;
|
||||||
};
|
};
|
||||||
|
in
|
||||||
|
# Don't bother wrapping unless we actually have plugins, since the wrapper will stop automatic downloading
|
||||||
|
# of plugins, which might be counterintuitive if someone just wants a vanilla Terraform.
|
||||||
|
if actualPlugins == []
|
||||||
|
then terraform.overrideAttrs (orig: { passthru = orig.passthru // passthru; })
|
||||||
|
else stdenv.mkDerivation {
|
||||||
|
name = "${terraform.name}-with-plugins";
|
||||||
|
buildInputs = [ makeWrapper ];
|
||||||
|
|
||||||
|
buildCommand = ''
|
||||||
|
mkdir -p $out/bin/
|
||||||
|
makeWrapper "${terraform.bin}/bin/terraform" "$out/bin/terraform" \
|
||||||
|
--set NIX_TERRAFORM_PLUGIN_DIR "${buildEnv { name = "tf-plugin-env"; paths = actualPlugins; }}/bin"
|
||||||
|
'';
|
||||||
|
|
||||||
|
inherit passthru;
|
||||||
};
|
};
|
||||||
in withPlugins (_: []);
|
in withPlugins (_: []);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user