tangled
alpha
login
or
join now
pyrox.dev
/
nixpkgs
lol
0
fork
atom
overview
issues
pulls
pipelines
terraform: noop 0.10 plugins mechanism when unused
Dan Peebles
8 years ago
11753b32
b291ead4
+26
-16
1 changed file
expand all
collapse all
unified
split
pkgs
applications
networking
cluster
terraform
default.nix
+26
-16
pkgs/applications/networking/cluster/terraform/default.nix
···
40
41
pluggable = terraform:
42
let
43
-
withPlugins = plugins: stdenv.mkDerivation {
44
-
name = "${terraform.name}-with-plugins";
45
-
buildInputs = [ makeWrapper ];
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
-
'';
52
53
-
passthru = {
54
-
withPlugins = newplugins: withPlugins (x: newplugins x ++ plugins x);
0
0
0
0
0
0
0
0
0
0
0
55
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
-
};
0
0
62
in withPlugins (_: []);
63
64
plugins = {
···
40
41
pluggable = terraform:
42
let
43
+
withPlugins = plugins:
44
+
let
45
+
actualPlugins = plugins terraform.plugins;
46
47
+
passthru = {
48
+
withPlugins = newplugins: withPlugins (x: newplugins x ++ actualPlugins);
0
0
0
49
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 ];
63
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
+
};
72
in withPlugins (_: []);
73
74
plugins = {