summary refs log tree commit diff
path: root/pkgs/applications/networking/cluster/terraform/default.nix
diff options
context:
space:
mode:
authorDan Peebles <pumpkin@me.com>2017-08-30 12:25:34 -0400
committerDan Peebles <pumpkin@me.com>2017-08-30 18:35:26 -0400
commit80319c123876064df40235eb21ab9ddd2d5a241a (patch)
treef8a8f0b5d77df8e6ed32516f268174d0e09b3c31 /pkgs/applications/networking/cluster/terraform/default.nix
parent769c44d9d87b4a2f39bd1f854fd5a506cd517150 (diff)
downloadnixlib-80319c123876064df40235eb21ab9ddd2d5a241a.tar
nixlib-80319c123876064df40235eb21ab9ddd2d5a241a.tar.gz
nixlib-80319c123876064df40235eb21ab9ddd2d5a241a.tar.bz2
nixlib-80319c123876064df40235eb21ab9ddd2d5a241a.tar.lz
nixlib-80319c123876064df40235eb21ab9ddd2d5a241a.tar.xz
nixlib-80319c123876064df40235eb21ab9ddd2d5a241a.tar.zst
nixlib-80319c123876064df40235eb21ab9ddd2d5a241a.zip
terraform: manage 0.10 plugins with Nix
Also add a few starter plugins/providers
Diffstat (limited to 'pkgs/applications/networking/cluster/terraform/default.nix')
-rw-r--r--pkgs/applications/networking/cluster/terraform/default.nix38
1 files changed, 35 insertions, 3 deletions
diff --git a/pkgs/applications/networking/cluster/terraform/default.nix b/pkgs/applications/networking/cluster/terraform/default.nix
index 8fd76f7df75d..efff9282bd3a 100644
--- a/pkgs/applications/networking/cluster/terraform/default.nix
+++ b/pkgs/applications/networking/cluster/terraform/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, lib, buildGoPackage, fetchpatch, fetchFromGitHub }:
+{ stdenv, lib, buildEnv, buildGoPackage, fetchpatch, fetchFromGitHub, makeWrapper }:
 
 let
   goPackagePath = "github.com/hashicorp/terraform";
@@ -37,6 +37,36 @@ let
         maintainers = with maintainers; [ jgeerds zimbatm peterhoeg ];
       };
     } // attrs');
+
+  pluggable = terraform:
+    let
+      withPlugins = plugins: 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 = plugins terraform.plugins; }}/bin"
+        '';
+
+        passthru = {
+          withPlugins = newplugins: withPlugins (x: newplugins x ++ plugins x);
+
+          # Ouch
+          overrideDerivation = f: (pluggable (terraform.overrideDerivation f)).withPlugins plugins;
+          overrideAttrs = f: (pluggable (terraform.overrideAttrs f)).withPlugins plugins;
+          override = x: (pluggable (terraform.override x)).withPlugins plugins;
+        };
+      };
+    in withPlugins (_: []);
+
+  plugins = {
+    aws = import providers/aws.nix { inherit stdenv lib buildGoPackage fetchFromGitHub; };
+    azurerm = import providers/azurerm.nix { inherit stdenv lib buildGoPackage fetchFromGitHub; };
+    google = import providers/google.nix { inherit stdenv lib buildGoPackage fetchFromGitHub; };
+    kubernetes = import providers/kubernetes.nix { inherit stdenv lib buildGoPackage fetchFromGitHub; };
+  };
 in {
   terraform_0_8_5 = generic {
     version = "0.8.5";
@@ -55,8 +85,10 @@ in {
     doCheck = false;
   };
 
-  terraform_0_10 = generic {
+  terraform_0_10 = pluggable (generic {
     version = "0.10.2";
     sha256 = "1q7za7jcfqv914a3ynfl7hrqbgwcahgm418kivjrac6p1q26w502";
-  };
+    patches = [ ./provider-path.patch ];
+    passthru = { inherit plugins; };
+  });
 }