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
|
2020-10-05 23:52:33 +01:00
|
|
|
, runtimeShell
|
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;
|
|
|
|
|
|
|
|
# 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
|
|
|
|
|
|
|
# Google is now using the vendored go modules, which works a bit differently
|
|
|
|
# and is not 100% compatible with the pre-modules vendored folders.
|
|
|
|
#
|
|
|
|
# Instead of switching to goModules which requires a goModSha256, patch the
|
|
|
|
# goPackage derivation so it can install the top-level.
|
|
|
|
patchGoModVendor = drv:
|
|
|
|
drv.overrideAttrs (attrs: {
|
|
|
|
buildFlags = "-mod=vendor";
|
|
|
|
|
|
|
|
# override configurePhase to not move the source into GOPATH
|
|
|
|
configurePhase = ''
|
|
|
|
export GOPATH=$NIX_BUILD_TOP/go:$GOPATH
|
|
|
|
export GOCACHE=$TMPDIR/go-cache
|
|
|
|
export GO111MODULE=on
|
|
|
|
'';
|
|
|
|
|
|
|
|
# just build and install into $GOPATH/bin
|
|
|
|
buildPhase = ''
|
|
|
|
go install -mod=vendor -v -p 16 .
|
2020-09-27 23:20:41 +01:00
|
|
|
|
|
|
|
runHook postBuild
|
2020-03-24 15:03:21 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
# don't run the tests, they are broken in this setup
|
|
|
|
doCheck = false;
|
|
|
|
});
|
|
|
|
|
|
|
|
# These providers are managed with the ./update-all script
|
2020-11-09 22:33:46 +00:00
|
|
|
automated-providers = lib.mapAttrs (_: attrs:
|
|
|
|
(if (lib.hasAttr "vendorSha256" attrs) then buildWithGoModule else buildWithGoPackage)
|
|
|
|
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
|
|
|
# Override providers that use Go modules + vendor/ folder
|
2020-03-24 15:03:21 +00:00
|
|
|
google = patchGoModVendor automated-providers.google;
|
|
|
|
google-beta = patchGoModVendor automated-providers.google-beta;
|
2020-04-26 12:06:38 +01:00
|
|
|
ibm = patchGoModVendor automated-providers.ibm;
|
2020-03-24 15:03:21 +00:00
|
|
|
|
2020-09-30 21:10:06 +01:00
|
|
|
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
|
|
|
|
'';
|
|
|
|
});
|
|
|
|
|
2020-04-26 12:06:38 +01:00
|
|
|
# Packages that don't fit the default model
|
|
|
|
ansible = callPackage ./ansible {};
|
2020-10-29 17:07:26 +00:00
|
|
|
cloudfoundry = callPackage ./cloudfoundry {};
|
2020-04-26 12:06:38 +01:00
|
|
|
elasticsearch = callPackage ./elasticsearch {};
|
2020-02-07 06:21:11 +00:00
|
|
|
gandi = callPackage ./gandi {};
|
2020-11-02 23:24:54 +00:00
|
|
|
hcloud = callPackage ./hcloud {};
|
2020-02-07 06:21:11 +00:00
|
|
|
keycloak = callPackage ./keycloak {};
|
2018-09-28 19:28:38 +01:00
|
|
|
libvirt = callPackage ./libvirt {};
|
2020-11-04 18:22:57 +00:00
|
|
|
linuxbox = callPackage ./linuxbox {};
|
2020-03-16 20:58:57 +00:00
|
|
|
lxd = callPackage ./lxd {};
|
2020-07-14 15:05:39 +01:00
|
|
|
shell = callPackage ./shell {};
|
2020-04-26 12:35:16 +01:00
|
|
|
vpsadmin = callPackage ./vpsadmin {};
|
2020-03-24 15:03:21 +00:00
|
|
|
};
|
|
|
|
in
|
|
|
|
automated-providers // special-providers
|