From 5f9073ccc597953f1627d02fa8fa695355502e6a Mon Sep 17 00:00:00 2001 From: Jonas Chevalier Date: Tue, 5 Oct 2021 17:21:45 +0000 Subject: [PATCH] terraform-providers.mkProvider: init (#140465) Expose how the providers are being created. That way, users can more easily extend or override the list of providers that they want to use. For example, you need a new AWS provider version: ```nix terraform.withPlugins (p: [ (p.mkProvider rec { owner = "hashicorp"; provider-source-address = "registry.terraform.io/hashicorp/aws"; repo = "terraform-provider-aws"; rev = "v${version}"; sha256 = "0fa61i172maanxmxz28mj7mkgrs9a5bs61mlvb0d5y97lv6pm2xg"; vendorSha256 ="1s22k4b2zq5n0pz6iqbqsf6f7chsbvkpdn432rvyshcryxlklfvl"; version = "3.56.0"; }) ]) ``` --- .../cluster/terraform-providers/default.nix | 29 ++++++++++--------- .../networking/cluster/terraform/default.nix | 2 +- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/pkgs/applications/networking/cluster/terraform-providers/default.nix b/pkgs/applications/networking/cluster/terraform-providers/default.nix index 48923330afee..54959e458314 100644 --- a/pkgs/applications/networking/cluster/terraform-providers/default.nix +++ b/pkgs/applications/networking/cluster/terraform-providers/default.nix @@ -39,25 +39,28 @@ let passthru = data; }; - # These providers are managed with the ./update-all script - automated-providers = lib.mapAttrs (_: attrs: + # Our generic constructor to build new providers + mkProvider = attrs: (if (lib.hasAttr "vendorSha256" attrs) then buildWithGoModule else buildWithGoPackage) - attrs) list; + attrs; + + # These providers are managed with the ./update-all script + automated-providers = lib.mapAttrs (_: attrs: mkProvider attrs) list; # These are the providers that don't fall in line with the default model special-providers = { # Packages that don't fit the default model - ansible = callPackage ./ansible {}; - cloudfoundry = callPackage ./cloudfoundry {}; - gandi = callPackage ./gandi {}; - hcloud = callPackage ./hcloud {}; - libvirt = callPackage ./libvirt {}; - linuxbox = callPackage ./linuxbox {}; - lxd = callPackage ./lxd {}; - vpsadmin = callPackage ./vpsadmin {}; - vercel = callPackage ./vercel {}; + ansible = callPackage ./ansible { }; + cloudfoundry = callPackage ./cloudfoundry { }; + gandi = callPackage ./gandi { }; + hcloud = callPackage ./hcloud { }; + libvirt = callPackage ./libvirt { }; + linuxbox = callPackage ./linuxbox { }; + lxd = callPackage ./lxd { }; + vpsadmin = callPackage ./vpsadmin { }; + vercel = callPackage ./vercel { }; } // (lib.optionalAttrs (config.allowAliases or false) { kubernetes-alpha = throw "This has been merged as beta into the kubernetes provider. See https://www.hashicorp.com/blog/beta-support-for-crds-in-the-terraform-provider-for-kubernetes for details"; }); in - automated-providers // special-providers +automated-providers // special-providers // { inherit mkProvider; } diff --git a/pkgs/applications/networking/cluster/terraform/default.nix b/pkgs/applications/networking/cluster/terraform/default.nix index 85b6cf679a9a..cab256d92708 100644 --- a/pkgs/applications/networking/cluster/terraform/default.nix +++ b/pkgs/applications/networking/cluster/terraform/default.nix @@ -114,7 +114,7 @@ let passthru = { withPlugins = newplugins: withPlugins (x: newplugins x ++ actualPlugins); - full = withPlugins lib.attrValues; + full = withPlugins (p: lib.filter lib.isDerivation (lib.attrValues p)); # Ouch overrideDerivation = f: