Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{ 2 lib, 3 stdenv, 4 buildGoModule, 5 buildGo123Module, 6 fetchFromGitHub, 7 fetchFromGitLab, 8 callPackage, 9 config, 10 writeShellScript, 11 12 cdrtools, # libvirt 13}: 14let 15 # Our generic constructor to build new providers. 16 # 17 # Is designed to combine with the terraform.withPlugins implementation. 18 mkProvider = lib.makeOverridable ( 19 { 20 owner, 21 repo, 22 rev, 23 spdx ? "UNSET", 24 version ? lib.removePrefix "v" rev, 25 hash, 26 vendorHash, 27 deleteVendor ? false, 28 proxyVendor ? false, 29 mkProviderFetcher ? fetchFromGitHub, 30 mkProviderGoModule ? buildGoModule, 31 # "https://registry.terraform.io/providers/vancluever/acme" 32 homepage ? "", 33 # "registry.terraform.io/vancluever/acme" 34 provider-source-address ? 35 lib.replaceStrings [ "https://registry" ".io/providers" ] [ "registry" ".io" ] 36 homepage, 37 ... 38 }@attrs: 39 assert lib.stringLength provider-source-address > 0; 40 mkProviderGoModule { 41 pname = repo; 42 inherit 43 vendorHash 44 version 45 deleteVendor 46 proxyVendor 47 ; 48 subPackages = [ "." ]; 49 doCheck = false; 50 # https://github.com/hashicorp/terraform-provider-scaffolding/blob/a8ac8375a7082befe55b71c8cbb048493dd220c2/.goreleaser.yml 51 # goreleaser (used for builds distributed via terraform registry) requires that CGO is disabled 52 env.CGO_ENABLED = 0; 53 ldflags = [ 54 "-s" 55 "-w" 56 "-X main.version=${version}" 57 "-X main.commit=${rev}" 58 ]; 59 src = mkProviderFetcher { 60 name = "source-${rev}"; 61 inherit 62 owner 63 repo 64 rev 65 hash 66 ; 67 }; 68 69 meta = { 70 inherit homepage; 71 license = lib.getLicenseFromSpdxId spdx; 72 }; 73 74 # Move the provider to libexec 75 postInstall = '' 76 dir=$out/libexec/terraform-providers/${provider-source-address}/${version}/''${GOOS}_''${GOARCH} 77 mkdir -p "$dir" 78 mv $out/bin/* "$dir/terraform-provider-$(basename ${provider-source-address})_${version}" 79 rmdir $out/bin 80 ''; 81 82 # Keep the attributes around for later consumption 83 passthru = attrs // { 84 inherit provider-source-address; 85 updateScript = writeShellScript "update" '' 86 provider="$(basename ${provider-source-address})" 87 ./pkgs/applications/networking/cluster/terraform-providers/update-provider "$provider" 88 ''; 89 }; 90 } 91 ); 92 93 list = lib.importJSON ./providers.json; 94 95 # These providers are managed with the ./update-all script 96 automated-providers = lib.mapAttrs (_: attrs: mkProvider attrs) list; 97 98 # These are the providers that don't fall in line with the default model 99 special-providers = { 100 aws = automated-providers.aws.override { mkProviderGoModule = buildGo123Module; }; 101 # github api seems to be broken, doesn't just fail to recognize the license, it's ignored entirely. 102 checkly = automated-providers.checkly.override { spdx = "MIT"; }; 103 gitlab = automated-providers.gitlab.override { 104 mkProviderFetcher = fetchFromGitLab; 105 owner = "gitlab-org"; 106 }; 107 # actions update always fails but can't reproduce the failure. 108 heroku = automated-providers.heroku.override { spdx = "MPL-2.0"; }; 109 # mkisofs needed to create ISOs holding cloud-init data and wrapped to terraform via deecb4c1aab780047d79978c636eeb879dd68630 110 libvirt = automated-providers.libvirt.overrideAttrs (_: { 111 propagatedBuildInputs = [ cdrtools ]; 112 }); 113 minio = automated-providers.minio.override { spdx = "AGPL-3.0-only"; }; 114 }; 115 116 # Put all the providers we not longer support in this list. 117 removed-providers = 118 let 119 archived = 120 name: date: throw "the ${name} terraform provider has been archived by upstream on ${date}"; 121 removed = name: date: throw "the ${name} terraform provider removed from nixpkgs on ${date}"; 122 in 123 lib.optionalAttrs config.allowAliases { 124 fly = archived "fly" "2023/10"; 125 }; 126 127 # excluding aliases, used by terraform-full 128 actualProviders = automated-providers // special-providers; 129in 130actualProviders // removed-providers // { inherit actualProviders mkProvider; }