2018-09-28 19:28:38 +01:00
|
|
|
{ lib
|
2020-11-09 22:33:46 +00:00
|
|
|
, buildGoModule
|
2018-09-28 19:28:38 +01:00
|
|
|
, buildGoPackage
|
|
|
|
, fetchFromGitHub
|
|
|
|
, callPackage
|
2021-08-10 19:43:24 +01:00
|
|
|
, config
|
2018-09-28 19:28:38 +01:00
|
|
|
}:
|
2017-09-01 15:49:24 +01:00
|
|
|
let
|
2020-09-30 21:20:18 +01:00
|
|
|
list = lib.importJSON ./providers.json;
|
2017-09-08 19:36:43 +01:00
|
|
|
|
2020-11-09 22:33:46 +00:00
|
|
|
buildWithGoModule = data:
|
|
|
|
buildGoModule {
|
|
|
|
pname = data.repo;
|
|
|
|
version = data.version;
|
|
|
|
subPackages = [ "." ];
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
inherit (data) owner repo rev sha256;
|
|
|
|
};
|
|
|
|
vendorSha256 = data.vendorSha256 or null;
|
2021-08-30 08:40:51 +01:00
|
|
|
deleteVendor = data.deleteVendor or false;
|
2020-11-09 22:33:46 +00:00
|
|
|
|
|
|
|
# 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:
|
2020-10-09 11:44:23 +01:00
|
|
|
buildGoPackage {
|
|
|
|
pname = data.repo;
|
|
|
|
version = data.version;
|
|
|
|
goPackagePath = "github.com/${data.owner}/${data.repo}";
|
2019-01-18 17:49:19 +00:00
|
|
|
subPackages = [ "." ];
|
2017-09-08 19:36:43 +01:00
|
|
|
src = fetchFromGitHub {
|
2020-10-09 11:44:23 +01:00
|
|
|
inherit (data) owner repo rev sha256;
|
2017-09-08 19:36:43 +01:00
|
|
|
};
|
2018-02-06 21:09:22 +00:00
|
|
|
# Terraform allow checking the provider versions, but this breaks
|
|
|
|
# if the versions are not provided via file paths.
|
2020-10-09 11:44:23 +01:00
|
|
|
postBuild = "mv $NIX_BUILD_TOP/go/bin/${data.repo}{,_v${data.version}}";
|
|
|
|
passthru = data;
|
2017-09-01 15:49:24 +01:00
|
|
|
};
|
2020-03-24 15:03:21 +00:00
|
|
|
|
2021-10-05 18:21:45 +01:00
|
|
|
# Our generic constructor to build new providers
|
|
|
|
mkProvider = attrs:
|
2020-11-09 22:33:46 +00:00
|
|
|
(if (lib.hasAttr "vendorSha256" attrs) then buildWithGoModule else buildWithGoPackage)
|
2021-10-05 18:21:45 +01:00
|
|
|
attrs;
|
|
|
|
|
|
|
|
# These providers are managed with the ./update-all script
|
|
|
|
automated-providers = lib.mapAttrs (_: attrs: mkProvider attrs) list;
|
2020-03-24 15:03:21 +00:00
|
|
|
|
|
|
|
# These are the providers that don't fall in line with the default model
|
|
|
|
special-providers = {
|
2020-04-26 12:06:38 +01:00
|
|
|
# Packages that don't fit the default model
|
2021-10-05 18:21:45 +01:00
|
|
|
ansible = callPackage ./ansible { };
|
|
|
|
cloudfoundry = callPackage ./cloudfoundry { };
|
|
|
|
gandi = callPackage ./gandi { };
|
|
|
|
hcloud = callPackage ./hcloud { };
|
|
|
|
libvirt = callPackage ./libvirt { };
|
|
|
|
linuxbox = callPackage ./linuxbox { };
|
|
|
|
lxd = callPackage ./lxd { };
|
2021-10-28 17:09:13 +01:00
|
|
|
teleport = callPackage ./teleport { };
|
2021-10-05 18:21:45 +01:00
|
|
|
vpsadmin = callPackage ./vpsadmin { };
|
|
|
|
vercel = callPackage ./vercel { };
|
2021-08-10 19:43:24 +01:00
|
|
|
} // (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";
|
|
|
|
});
|
2020-03-24 15:03:21 +00:00
|
|
|
in
|
2021-10-05 18:21:45 +01:00
|
|
|
automated-providers // special-providers // { inherit mkProvider; }
|