13 # Our generic constructor to build new providers.
15 # Is designed to combine with the terraform.withPlugins implementation.
16 mkProvider = lib.makeOverridable
21 , version ? lib.removePrefix "v" rev
24 , deleteVendor ? false
26 , mkProviderFetcher ? fetchFromGitHub
27 , mkProviderGoModule ? buildGoModule
28 # "https://registry.terraform.io/providers/vancluever/acme"
30 # "registry.terraform.io/vancluever/acme"
31 , provider-source-address ? lib.replaceStrings [ "https://registry" ".io/providers" ] [ "registry" ".io" ] homepage
34 assert lib.stringLength provider-source-address > 0;
37 inherit vendorHash version deleteVendor proxyVendor;
38 subPackages = [ "." ];
40 # https://github.com/hashicorp/terraform-provider-scaffolding/blob/a8ac8375a7082befe55b71c8cbb048493dd220c2/.goreleaser.yml
41 # goreleaser (used for builds distributed via terraform registry) requires that CGO is disabled
43 ldflags = [ "-s" "-w" "-X main.version=${version}" "-X main.commit=${rev}" ];
44 src = mkProviderFetcher {
45 name = "source-${rev}";
46 inherit owner repo rev hash;
51 license = lib.getLicenseFromSpdxId spdx;
54 # Move the provider to libexec
56 dir=$out/libexec/terraform-providers/${provider-source-address}/${version}/''${GOOS}_''${GOARCH}
58 mv $out/bin/* "$dir/terraform-provider-$(basename ${provider-source-address})_${version}"
62 # Keep the attributes around for later consumption
64 inherit provider-source-address;
65 updateScript = writeShellScript "update" ''
66 provider="$(basename ${provider-source-address})"
67 ./pkgs/applications/networking/cluster/terraform-providers/update-provider "$provider"
72 list = lib.importJSON ./providers.json;
74 # These providers are managed with the ./update-all script
75 automated-providers = lib.mapAttrs (_: attrs: mkProvider attrs) list;
77 # These are the providers that don't fall in line with the default model
80 # github api seems to be broken, doesn't just fail to recognize the license, it's ignored entirely.
81 checkly = automated-providers.checkly.override { spdx = "MIT"; };
82 gitlab = automated-providers.gitlab.override { mkProviderFetcher = fetchFromGitLab; owner = "gitlab-org"; };
83 # actions update always fails but can't reproduce the failure.
84 heroku = automated-providers.heroku.override { spdx = "MPL-2.0"; };
85 # mkisofs needed to create ISOs holding cloud-init data and wrapped to terraform via deecb4c1aab780047d79978c636eeb879dd68630
86 libvirt = automated-providers.libvirt.overrideAttrs (_: { propagatedBuildInputs = [ cdrtools ]; });
87 minio = automated-providers.minio.override { spdx = "AGPL-3.0-only"; };
90 # Put all the providers we not longer support in this list.
93 archived = name: date: throw "the ${name} terraform provider has been archived by upstream on ${date}";
94 removed = name: date: throw "the ${name} terraform provider removed from nixpkgs on ${date}";
96 lib.optionalAttrs config.allowAliases {
97 fly = archived "fly" "2023/10";
100 # excluding aliases, used by terraform-full
101 actualProviders = automated-providers // special-providers;
103 actualProviders // removed-providers // { inherit actualProviders mkProvider; }