nixpkgs-suyu/pkgs/applications/networking/cluster/terraform-providers/default.nix
Jean-François Roche b2071f5035
terraform-providers.elasticsearch: 0.7.0 -> 1.5.2
Define provider in `providers.json`.
Remove custom build for terraform provider.
2021-02-11 00:13:25 +01:00

69 lines
2.3 KiB
Nix

{ lib
, buildGoModule
, buildGoPackage
, fetchFromGitHub
, callPackage
, runtimeShell
}:
let
list = lib.importJSON ./providers.json;
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;
goPackagePath = "github.com/${data.owner}/${data.repo}";
subPackages = [ "." ];
src = fetchFromGitHub {
inherit (data) owner repo rev sha256;
};
# 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;
};
# These providers are managed with the ./update-all script
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 = {
acme = automated-providers.acme.overrideAttrs (attrs: {
prePatch = attrs.prePatch or "" + ''
substituteInPlace go.mod --replace terraform-providers/terraform-provider-acme getstackhead/terraform-provider-acme
substituteInPlace main.go --replace terraform-providers/terraform-provider-acme getstackhead/terraform-provider-acme
'';
});
# Packages that don't fit the default model
ansible = callPackage ./ansible {};
cloudfoundry = callPackage ./cloudfoundry {};
gandi = callPackage ./gandi {};
hcloud = callPackage ./hcloud {};
keycloak = callPackage ./keycloak {};
libvirt = callPackage ./libvirt {};
linuxbox = callPackage ./linuxbox {};
lxd = callPackage ./lxd {};
vpsadmin = callPackage ./vpsadmin {};
vercel = callPackage ./vercel {};
};
in
automated-providers // special-providers