terraform: noop 0.10 plugins mechanism when unused

+26 -16
+26 -16
pkgs/applications/networking/cluster/terraform/default.nix
··· 40 40 41 41 pluggable = terraform: 42 42 let 43 - withPlugins = plugins: stdenv.mkDerivation { 44 - name = "${terraform.name}-with-plugins"; 45 - buildInputs = [ makeWrapper ]; 43 + withPlugins = plugins: 44 + let 45 + actualPlugins = plugins terraform.plugins; 46 46 47 - buildCommand = '' 48 - mkdir -p $out/bin/ 49 - makeWrapper "${terraform.bin}/bin/terraform" "$out/bin/terraform" \ 50 - --set NIX_TERRAFORM_PLUGIN_DIR "${buildEnv { name = "tf-plugin-env"; paths = plugins terraform.plugins; }}/bin" 51 - ''; 47 + passthru = { 48 + withPlugins = newplugins: withPlugins (x: newplugins x ++ actualPlugins); 52 49 53 - passthru = { 54 - withPlugins = newplugins: withPlugins (x: newplugins x ++ plugins x); 50 + # Ouch 51 + overrideDerivation = f: (pluggable (terraform.overrideDerivation f)).withPlugins plugins; 52 + overrideAttrs = f: (pluggable (terraform.overrideAttrs f)).withPlugins plugins; 53 + override = x: (pluggable (terraform.override x)).withPlugins plugins; 54 + }; 55 + in 56 + # Don't bother wrapping unless we actually have plugins, since the wrapper will stop automatic downloading 57 + # of plugins, which might be counterintuitive if someone just wants a vanilla Terraform. 58 + if actualPlugins == [] 59 + then terraform.overrideAttrs (orig: { passthru = orig.passthru // passthru; }) 60 + else stdenv.mkDerivation { 61 + name = "${terraform.name}-with-plugins"; 62 + buildInputs = [ makeWrapper ]; 55 63 56 - # Ouch 57 - overrideDerivation = f: (pluggable (terraform.overrideDerivation f)).withPlugins plugins; 58 - overrideAttrs = f: (pluggable (terraform.overrideAttrs f)).withPlugins plugins; 59 - override = x: (pluggable (terraform.override x)).withPlugins plugins; 60 - }; 61 - }; 64 + buildCommand = '' 65 + mkdir -p $out/bin/ 66 + makeWrapper "${terraform.bin}/bin/terraform" "$out/bin/terraform" \ 67 + --set NIX_TERRAFORM_PLUGIN_DIR "${buildEnv { name = "tf-plugin-env"; paths = actualPlugins; }}/bin" 68 + ''; 69 + 70 + inherit passthru; 71 + }; 62 72 in withPlugins (_: []); 63 73 64 74 plugins = {