uboot: (firmwareOdroidC2/C4) don't invoke patch tool, use patches = [] instead
https://github.com/NixOS/nixpkgs/blob/master/pkgs/stdenv/generic/setup.sh#L948 this can do it nicely. Signed-off-by: Anton Arapov <anton@deadbeef.mx>
This commit is contained in:
commit
56de2bcd43
30691 changed files with 3076956 additions and 0 deletions
|
|
@ -0,0 +1,84 @@
|
|||
{ lib
|
||||
, buildGoModule
|
||||
, buildGo118Module
|
||||
, fetchFromGitHub
|
||||
, callPackage
|
||||
, config
|
||||
|
||||
, cdrtools # libvirt
|
||||
}:
|
||||
let
|
||||
# Our generic constructor to build new providers.
|
||||
#
|
||||
# Is designed to combine with the terraform.withPlugins implementation.
|
||||
mkProvider = lib.makeOverridable
|
||||
({ owner
|
||||
, repo
|
||||
, rev
|
||||
, version
|
||||
, sha256
|
||||
, vendorSha256 ? throw "vendorSha256 missing: please use `buildGoModule`" /* added 2022/01 */
|
||||
, deleteVendor ? false
|
||||
, proxyVendor ? false
|
||||
, mkProviderGoModule ? buildGoModule
|
||||
, # Looks like "registry.terraform.io/vancluever/acme"
|
||||
provider-source-address
|
||||
}@attrs:
|
||||
mkProviderGoModule {
|
||||
pname = repo;
|
||||
inherit vendorSha256 version deleteVendor proxyVendor;
|
||||
subPackages = [ "." ];
|
||||
doCheck = false;
|
||||
# https://github.com/hashicorp/terraform-provider-scaffolding/blob/a8ac8375a7082befe55b71c8cbb048493dd220c2/.goreleaser.yml
|
||||
# goreleaser (used for builds distributed via terraform registry) requires that CGO is disabled
|
||||
CGO_ENABLED = 0;
|
||||
ldflags = [ "-s" "-w" "-X main.version=${version}" "-X main.commit=${rev}" ];
|
||||
src = fetchFromGitHub {
|
||||
name = "source-${rev}";
|
||||
inherit owner repo rev sha256;
|
||||
};
|
||||
|
||||
# Move the provider to libexec
|
||||
postInstall = ''
|
||||
dir=$out/libexec/terraform-providers/${provider-source-address}/${version}/''${GOOS}_''${GOARCH}
|
||||
mkdir -p "$dir"
|
||||
mv $out/bin/* "$dir/terraform-provider-$(basename ${provider-source-address})_${version}"
|
||||
rmdir $out/bin
|
||||
'';
|
||||
|
||||
# Keep the attributes around for later consumption
|
||||
passthru = attrs;
|
||||
});
|
||||
|
||||
list = lib.importJSON ./providers.json;
|
||||
|
||||
# These providers are managed with the ./update-all script
|
||||
automated-providers = lib.mapAttrs (_: attrs: mkProvider attrs) list;
|
||||
|
||||
# These are the providers that don't fall in line with the default model
|
||||
special-providers =
|
||||
{
|
||||
# Packages that don't fit the default model
|
||||
|
||||
brightbox = automated-providers.brightbox.override { mkProviderGoModule = buildGo118Module; };
|
||||
# mkisofs needed to create ISOs holding cloud-init data,
|
||||
# and wrapped to terraform via deecb4c1aab780047d79978c636eeb879dd68630
|
||||
libvirt = automated-providers.libvirt.overrideAttrs (_: { propagatedBuildInputs = [ cdrtools ]; });
|
||||
};
|
||||
|
||||
# Put all the providers we not longer support in this list.
|
||||
removed-providers =
|
||||
let
|
||||
archived = name: date: throw "the ${name} terraform provider has been archived by upstream on ${date}";
|
||||
removed = name: date: throw "the ${name} terraform provider removed from nixpkgs on ${date}";
|
||||
in
|
||||
lib.optionalAttrs config.allowAliases {
|
||||
opc = archived "opc" "2022/05";
|
||||
oraclepaas = archived "oraclepaas" "2022/05";
|
||||
template = archived "template" "2022/05";
|
||||
};
|
||||
|
||||
# excluding aliases, used by terraform-full
|
||||
actualProviders = automated-providers // special-providers;
|
||||
in
|
||||
actualProviders // removed-providers // { inherit actualProviders mkProvider; }
|
||||
File diff suppressed because it is too large
Load diff
|
|
@ -0,0 +1,25 @@
|
|||
#!/usr/bin/env nix-shell
|
||||
#! nix-shell -I nixpkgs=../../../../.. -i bash -p jq
|
||||
# shellcheck shell=bash
|
||||
|
||||
# Update all providers which have specified provider source address
|
||||
set -euo pipefail
|
||||
|
||||
readarray -t providers < <(
|
||||
jq -r 'to_entries
|
||||
| map_values(.value + { alias: .key })
|
||||
| .[]
|
||||
| select(."provider-source-address"?)
|
||||
| .alias' providers.json
|
||||
)
|
||||
|
||||
cat <<EOF
|
||||
Will update ${#providers[@]} providers:
|
||||
|
||||
${providers[*]}
|
||||
|
||||
EOF
|
||||
|
||||
for provider in "${providers[@]}"; do
|
||||
./update-provider "$@" "${provider}"
|
||||
done
|
||||
166
pkgs/applications/networking/cluster/terraform-providers/update-provider
Executable file
166
pkgs/applications/networking/cluster/terraform-providers/update-provider
Executable file
|
|
@ -0,0 +1,166 @@
|
|||
#!/usr/bin/env nix-shell
|
||||
#! nix-shell -I nixpkgs=../../../../.. -i bash -p coreutils curl git jq moreutils nix nix-prefetch
|
||||
# shellcheck shell=bash
|
||||
# vim: ft=sh
|
||||
#
|
||||
# Update a terraform provider to the latest version advertised at the
|
||||
# provider source address.
|
||||
#
|
||||
set -euo pipefail
|
||||
shopt -s inherit_errexit
|
||||
|
||||
show_usage() {
|
||||
cat <<DOC
|
||||
Usage: ./update-provider [--force] [--no-build] [<owner>/]<provider>
|
||||
|
||||
Update a single provider in the providers.json inventory file.
|
||||
|
||||
For example to update 'terraform-providers.aws' run:
|
||||
|
||||
./update-provider aws
|
||||
|
||||
If the provider is not in the list already, use the form '<owner>/<provider>'
|
||||
to add the provider to the list:
|
||||
|
||||
./update-provider hetznercloud/hcloud
|
||||
|
||||
Options:
|
||||
|
||||
* --force: Force the update even if the version matches.
|
||||
* --no-build: Don't build provider
|
||||
* --vendor-sha256 <sha256>: Override the SHA256 or "null".
|
||||
DOC
|
||||
}
|
||||
|
||||
force=
|
||||
provider=
|
||||
build=1
|
||||
vendorSha256=
|
||||
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case "$1" in
|
||||
-h | --help)
|
||||
show_usage
|
||||
exit
|
||||
;;
|
||||
--force)
|
||||
force=1
|
||||
shift
|
||||
;;
|
||||
--no-build)
|
||||
build=0
|
||||
shift
|
||||
;;
|
||||
--vendor-sha256)
|
||||
force=1
|
||||
vendorSha256=$2
|
||||
shift 2
|
||||
;;
|
||||
*)
|
||||
if [[ -n ${provider} ]]; then
|
||||
echo "ERROR: provider name was passed two times: '${provider}' and '$1'"
|
||||
echo "Use --help for more info"
|
||||
exit 1
|
||||
fi
|
||||
provider=$1
|
||||
shift
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [[ -z ${provider} ]]; then
|
||||
echo "ERROR: No providers specified!"
|
||||
echo
|
||||
show_usage
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Usage: read_attr <key>
|
||||
read_attr() {
|
||||
jq -r ".\"${provider}\".\"$1\"" providers.json
|
||||
}
|
||||
|
||||
# Usage: update_attr <key> <value>
|
||||
update_attr() {
|
||||
if [[ $2 == "null" ]]; then
|
||||
jq -S ".\"${provider}\".\"$1\" = null" providers.json | sponge providers.json
|
||||
else
|
||||
jq -S ".\"${provider}\".\"$1\" = \"$2\"" providers.json | sponge providers.json
|
||||
fi
|
||||
}
|
||||
|
||||
repo_root=$(git rev-parse --show-toplevel)
|
||||
|
||||
generate_hash() {
|
||||
nix-prefetch -I nixpkgs="${repo_root}" \
|
||||
"{ sha256 }: (import ${repo_root} {}).terraform-providers.${provider}.$1.overrideAttrs (_: { $2 = sha256; })"
|
||||
}
|
||||
|
||||
echo_provider() {
|
||||
echo "== terraform-providers.${provider}: $* =="
|
||||
}
|
||||
|
||||
if [[ ${provider} =~ ^[^/]+/[^/]+$ ]]; then
|
||||
echo_provider "init"
|
||||
source_address=registry.terraform.io/${provider}
|
||||
provider=$(basename "${provider}")
|
||||
update_attr "provider-source-address" "${source_address}"
|
||||
update_attr version "0"
|
||||
# create empty stings so nix-prefetch works
|
||||
update_attr sha256 ""
|
||||
update_attr vendorSha256 ""
|
||||
else
|
||||
source_address="$(read_attr provider-source-address)"
|
||||
fi
|
||||
|
||||
old_vendor_sha256=$(read_attr vendorSha256)
|
||||
old_version=$(read_attr version)
|
||||
|
||||
# The provider source address (used inside Terraform `required_providers` block) is
|
||||
# used to compute the registry API endpoint
|
||||
#
|
||||
# registry.terraform.io/hashicorp/aws (provider source address)
|
||||
# registry.terraform.io/providers/hashicorp/aws (provider URL for the website)
|
||||
# registry.terraform.io/v1/providers/hashicorp/aws (provider URL for the JSON API)
|
||||
registry_response=$(curl -s https://"${source_address/\///v1/providers/}")
|
||||
|
||||
version="$(jq -r '.version' <<<"${registry_response}")"
|
||||
if [[ ${old_version} == "${version}" && ${force} != 1 && -z ${vendorSha256} && ${old_vendor_sha256} != "${vendorSha256}" ]]; then
|
||||
echo_provider "already at version ${version}"
|
||||
exit
|
||||
fi
|
||||
if [[ ${version} =~ [[:alpha:]] && ${force} != 1 ]]; then
|
||||
echo_provider "not updating to unstable version ${version}"
|
||||
exit
|
||||
fi
|
||||
echo_provider "updating from ${old_version} to ${version}"
|
||||
update_attr version "${version}"
|
||||
|
||||
provider_source_url="$(jq -r '.source' <<<"${registry_response}")"
|
||||
|
||||
org="$(echo "${provider_source_url}" | cut -d '/' -f 4)"
|
||||
update_attr owner "${org}"
|
||||
repo="$(echo "${provider_source_url}" | cut -d '/' -f 5)"
|
||||
update_attr repo "${repo}"
|
||||
rev="$(jq -r '.tag' <<<"${registry_response}")"
|
||||
update_attr rev "${rev}"
|
||||
echo_provider "calculating sha256"
|
||||
sha256=$(generate_hash src outputHash)
|
||||
update_attr sha256 "${sha256}"
|
||||
|
||||
if [[ -z ${vendorSha256} ]]; then
|
||||
if [[ ${old_vendor_sha256} == null ]]; then
|
||||
vendorSha256=null
|
||||
else
|
||||
echo_provider "calculating vendorSha256"
|
||||
vendorSha256=$(generate_hash go-modules vendorSha256)
|
||||
fi
|
||||
fi
|
||||
|
||||
update_attr vendorSha256 "${vendorSha256}"
|
||||
|
||||
# Check that the provider builds
|
||||
if [[ ${build} == 1 ]]; then
|
||||
echo_provider "building"
|
||||
nix-build --no-out-link "${repo_root}" -A "terraform-providers.${provider}"
|
||||
fi
|
||||
Loading…
Add table
Add a link
Reference in a new issue