summaryrefslogtreecommitdiffstats
path: root/pkgs/applications/networking/cluster/terraform-providers
diff options
context:
space:
mode:
authorTimothy Stott <stott.timothy@gmail.com>2020-11-09 22:33:46 +0000
committerJonathan Ringer <jonringer@users.noreply.github.com>2020-11-24 05:42:49 -0800
commit31589fe918a19b09bc778ebbcd75b0ca1f445eaa (patch)
treecbaa2189ef2d9f6ca49e6e31ce0124e6c928d498 /pkgs/applications/networking/cluster/terraform-providers
parent4f165c6d7d4dcd216c95dc02a875d2ab09f65821 (diff)
terraform-providers: support providers with Go module
Diffstat (limited to 'pkgs/applications/networking/cluster/terraform-providers')
-rw-r--r--pkgs/applications/networking/cluster/terraform-providers/default.nix23
1 files changed, 21 insertions, 2 deletions
diff --git a/pkgs/applications/networking/cluster/terraform-providers/default.nix b/pkgs/applications/networking/cluster/terraform-providers/default.nix
index 6ce7ad6092af..a66da4748c14 100644
--- a/pkgs/applications/networking/cluster/terraform-providers/default.nix
+++ b/pkgs/applications/networking/cluster/terraform-providers/default.nix
@@ -1,4 +1,5 @@
{ lib
+, buildGoModule
, buildGoPackage
, fetchFromGitHub
, callPackage
@@ -7,7 +8,23 @@
let
list = lib.importJSON ./providers.json;
- toDrv = name: data:
+ buildWithGoModule = data:
+ buildGoModule {
+ pname = data.repo;
+ version = data.version;
+ subPackages = [ "." ];
+ src = fetchFromGitHub {
+ inherit (data) owner repo rev sha256;
+ };
+ vendorSha256 = data.vendorSha256 or null;
+
+ # Terraform allow checking the provider versions, but this breaks
+ # if the versions are not provided via file paths.
+ postBuild = "mv $NIX_BUILD_TOP/go/bin/${data.repo}{,_v${data.version}}";
+ passthru = data;
+ };
+
+ buildWithGoPackage = data:
buildGoPackage {
pname = data.repo;
version = data.version;
@@ -50,7 +67,9 @@ let
});
# These providers are managed with the ./update-all script
- automated-providers = lib.mapAttrs (toDrv) list;
+ automated-providers = lib.mapAttrs (_: attrs:
+ (if (lib.hasAttr "vendorSha256" attrs) then buildWithGoModule else buildWithGoPackage)
+ attrs) list;
# These are the providers that don't fall in line with the default model
special-providers = {