diff --git a/pkgs/applications/networking/cluster/terraform/default.nix b/pkgs/applications/networking/cluster/terraform/default.nix index 8643159aa8fb..cc7a93bdb537 100644 --- a/pkgs/applications/networking/cluster/terraform/default.nix +++ b/pkgs/applications/networking/cluster/terraform/default.nix @@ -71,13 +71,7 @@ let }; in withPlugins (_: []); - plugins = { - aws = import providers/aws.nix { inherit stdenv lib buildGoPackage fetchFromGitHub; }; - azurerm = import providers/azurerm.nix { inherit stdenv lib buildGoPackage fetchFromGitHub; }; - google = import providers/google.nix { inherit stdenv lib buildGoPackage fetchFromGitHub; }; - kubernetes = import providers/kubernetes.nix { inherit stdenv lib buildGoPackage fetchFromGitHub; }; - template = import providers/template.nix { inherit stdenv lib buildGoPackage fetchFromGitHub; }; - }; + plugins = import ./providers { inherit stdenv lib buildGoPackage fetchFromGitHub; }; in { terraform_0_8_5 = generic { version = "0.8.5"; diff --git a/pkgs/applications/networking/cluster/terraform/providers/aws.nix b/pkgs/applications/networking/cluster/terraform/providers/aws.nix deleted file mode 100644 index 744c13df3294..000000000000 --- a/pkgs/applications/networking/cluster/terraform/providers/aws.nix +++ /dev/null @@ -1,16 +0,0 @@ -{ stdenv, lib, buildGoPackage, fetchFromGitHub }: - -buildGoPackage rec { - pname = "terraform-provider-aws"; - name = "${pname}-${version}"; - version = "0.1.4"; - - goPackagePath = "github.com/terraform-providers/terraform-provider-aws"; - - src = fetchFromGitHub { - owner = "terraform-providers"; - repo = pname; - rev = "v${version}"; - sha256 = "0hqyvp1bgyfqq2lkjq5m5qxybagnxl9zrqiqfnlrfigdp0y31iz8"; - }; -} \ No newline at end of file diff --git a/pkgs/applications/networking/cluster/terraform/providers/azurerm.nix b/pkgs/applications/networking/cluster/terraform/providers/azurerm.nix deleted file mode 100644 index e6907d1b2aae..000000000000 --- a/pkgs/applications/networking/cluster/terraform/providers/azurerm.nix +++ /dev/null @@ -1,16 +0,0 @@ -{ stdenv, lib, buildGoPackage, fetchFromGitHub }: - -buildGoPackage rec { - pname = "terraform-provider-azurerm"; - name = "${pname}-${version}"; - version = "0.1.5"; - - goPackagePath = "github.com/terraform-providers/terraform-provider-azurerm"; - - src = fetchFromGitHub { - owner = "terraform-providers"; - repo = pname; - rev = "v${version}"; - sha256 = "02g8wnzwaii24nx5iin1yd4bx0rx22ly8aqhwa39mr5hsjj1qy4k"; - }; -} \ No newline at end of file diff --git a/pkgs/applications/networking/cluster/terraform/providers/data.nix b/pkgs/applications/networking/cluster/terraform/providers/data.nix new file mode 100644 index 000000000000..76eaa21a42ca --- /dev/null +++ b/pkgs/applications/networking/cluster/terraform/providers/data.nix @@ -0,0 +1,333 @@ +{ + aws = + { + pname = "terraform-provider-aws"; + version = "0.1.4"; + src = { + owner = "terraform-providers"; + repo = "terraform-provider-aws"; + rev = "v0.1.4"; + sha256 = "0hqyvp1bgyfqq2lkjq5m5qxybagnxl9zrqiqfnlrfigdp0y31iz8"; + }; + }; + azurerm = + { + pname = "terraform-provider-azurerm"; + version = "0.1.6"; + src = { + owner = "terraform-providers"; + repo = "terraform-provider-azurerm"; + rev = "v0.1.6"; + sha256 = "01hjr42gpkpwpz0chnkw8pf0yid0hqpdnfz65q5h2p8h627hg0c6"; + }; + }; + bitbucket = + { + pname = "terraform-provider-bitbucket"; + version = "0.1.0"; + src = { + owner = "terraform-providers"; + repo = "terraform-provider-bitbucket"; + rev = "v0.1.0"; + sha256 = "0c5aiq0p425h7c600wg5h3601l40airwz6cs724lc72fycbb4s43"; + }; + }; + chef = + { + pname = "terraform-provider-chef"; + version = "0.1.0"; + src = { + owner = "terraform-providers"; + repo = "terraform-provider-chef"; + rev = "v0.1.0"; + sha256 = "17fppyhxi0rd5v8khw2psdn2hdv5j79hxhinwkzrq5s4iccqk5dw"; + }; + }; + circonus = + { + pname = "terraform-provider-circonus"; + version = "0.1.0"; + src = { + owner = "terraform-providers"; + repo = "terraform-provider-circonus"; + rev = "v0.1.0"; + sha256 = "0v05g91yg2zh4wczp8mi3hmvwb35z0y9044bwy67nm1l624xlj64"; + }; + }; + cloudstack = + { + pname = "terraform-provider-cloudstack"; + version = "0.1.1"; + src = { + owner = "terraform-providers"; + repo = "terraform-provider-cloudstack"; + rev = "v0.1.1"; + sha256 = "09iqxpc5a6938qj1js2y9s4dcgk7hw69xga56ixpbbknms2yrhnb"; + }; + }; + cobbler = + { + pname = "terraform-provider-cobbler"; + version = "0.1.0"; + src = { + owner = "terraform-providers"; + repo = "terraform-provider-cobbler"; + rev = "v0.1.0"; + sha256 = "1867aqlz1v7scybaia9yakaxw76lh6y2whhajv5pqy1ng58rcgiz"; + }; + }; + consul = + { + pname = "terraform-provider-consul"; + version = "0.1.0"; + src = { + owner = "terraform-providers"; + repo = "terraform-provider-consul"; + rev = "v0.1.0"; + sha256 = "1d179m42iv2dy6wjzldllffwg6qxbg6gnvxrp6nzy75v7qp2aq94"; + }; + }; + datadog = + { + pname = "terraform-provider-datadog"; + version = "0.1.0"; + src = { + owner = "terraform-providers"; + repo = "terraform-provider-datadog"; + rev = "v0.1.0"; + sha256 = "1k3p0zxffhabs1xb6aw9189vbmh3ax10q4xi1qgjfjvla22byqmk"; + }; + }; + dme = + { + pname = "terraform-provider-dme"; + version = "0.1.0"; + src = { + owner = "terraform-providers"; + repo = "terraform-provider-dme"; + rev = "v0.1.0"; + sha256 = "1ipqw1sbx0i9rhxawsysrqxvf10z8ra2y86xwd4iz0f12x9drblv"; + }; + }; + dnsimple = + { + pname = "terraform-provider-dnsimple"; + version = "0.1.0"; + src = { + owner = "terraform-providers"; + repo = "terraform-provider-dnsimple"; + rev = "v0.1.0"; + sha256 = "0gkd5i69ldm5zn34p3k68aqk798g6g0d60gw7yp316l7mskvrx7h"; + }; + }; + dyn = + { + pname = "terraform-provider-dyn"; + version = "0.1.0"; + src = { + owner = "terraform-providers"; + repo = "terraform-provider-dyn"; + rev = "v0.1.0"; + sha256 = "1w727r2gz5hjmbzw9zir0n5nrr818adh4qj50n3vijqwbxciyq2p"; + }; + }; + google = + { + pname = "terraform-provider-google"; + version = "0.1.3"; + src = { + owner = "terraform-providers"; + repo = "terraform-provider-google"; + rev = "v0.1.3"; + sha256 = "1aa1hz0yc4g746m6dl04hc70rcrzx0py8kpdch3kim475bspclnf"; + }; + }; + http = + { + pname = "terraform-provider-http"; + version = "0.1.0"; + src = { + owner = "terraform-providers"; + repo = "terraform-provider-http"; + rev = "v0.1.0"; + sha256 = "1iy5fsl1j4wswbajnw0k6lagc2sz52idnswj1vmfc66x87ls0mah"; + }; + }; + ignition = + { + pname = "terraform-provider-ignition"; + version = "0.1.0"; + src = { + owner = "terraform-providers"; + repo = "terraform-provider-ignition"; + rev = "v0.1.0"; + sha256 = "03jvngd3fjyqmdzg2847p0k2fjyqykgmdng5vss4rcsn0n3b9d39"; + }; + }; + influxdb = + { + pname = "terraform-provider-influxdb"; + version = "0.1.0"; + src = { + owner = "terraform-providers"; + repo = "terraform-provider-influxdb"; + rev = "v0.1.0"; + sha256 = "0msc6maxsiwmsg8ppdfj1397c66llhaf15nc4hmr2h6dxqkb5wl5"; + }; + }; + logentries = + { + pname = "terraform-provider-logentries"; + version = "0.1.0"; + src = { + owner = "terraform-providers"; + repo = "terraform-provider-logentries"; + rev = "v0.1.0"; + sha256 = "11fkb84gqcq59wk5kqn3h428jrc2gkl659zxmkdldad6jdll9ypa"; + }; + }; + mailgun = + { + pname = "terraform-provider-mailgun"; + version = "0.1.0"; + src = { + owner = "terraform-providers"; + repo = "terraform-provider-mailgun"; + rev = "v0.1.0"; + sha256 = "1hjhjfxqbr43wa248c6hc91lx5b2gdw4vl92l2i6aqp17rbc0wfj"; + }; + }; + nomad = + { + pname = "terraform-provider-nomad"; + version = "0.1.0"; + src = { + owner = "terraform-providers"; + repo = "terraform-provider-nomad"; + rev = "v0.1.0"; + sha256 = "03sb31l59hxpp6zmnizxdm21jipz4mrzz9czk6ahhx7c8q0n0na8"; + }; + }; + oneandone = + { + pname = "terraform-provider-oneandone"; + version = "0.1.0"; + src = { + owner = "terraform-providers"; + repo = "terraform-provider-oneandone"; + rev = "v0.1.0"; + sha256 = "18bbpcprjib4d4skjdr76xjxi9091h5b3dls68y6bxkk6sh6av1i"; + }; + }; + opsgenie = + { + pname = "terraform-provider-opsgenie"; + version = "0.1.0"; + src = { + owner = "terraform-providers"; + repo = "terraform-provider-opsgenie"; + rev = "v0.1.0"; + sha256 = "0zs0cl6jl4rijcs6vv5k8k5pyf0zs52dlgqcnb1gzslh8sg5pdkm"; + }; + }; + ovh = + { + pname = "terraform-provider-ovh"; + version = "0.1.0"; + src = { + owner = "terraform-providers"; + repo = "terraform-provider-ovh"; + rev = "v0.1.0"; + sha256 = "052bnfw146h9nh3cw77clwwxbmw1gvaich2yw39v4b1ca8brm5dr"; + }; + }; + pagerduty = + { + pname = "terraform-provider-pagerduty"; + version = "0.1.2"; + src = { + owner = "terraform-providers"; + repo = "terraform-provider-pagerduty"; + rev = "v0.1.2"; + sha256 = "1dqzi53bnk4qcjhlimr13352nzb1nsij7354zapz2sgnz21v89mm"; + }; + }; + postgresql = + { + pname = "terraform-provider-postgresql"; + version = "0.1.0"; + src = { + owner = "terraform-providers"; + repo = "terraform-provider-postgresql"; + rev = "v0.1.0"; + sha256 = "0gg48b2zn18ynvhnabvyfvw5wif0m1a852798wahv8fbv5d1vh7j"; + }; + }; + profitbricks = + { + pname = "terraform-provider-profitbricks"; + version = "0.1.2"; + src = { + owner = "terraform-providers"; + repo = "terraform-provider-profitbricks"; + rev = "v0.1.2"; + sha256 = "105l0rijqmp7kmd7wygnhnj02q7y1rz0r8pj2mjzncb5pr48m3qp"; + }; + }; + scaleway = + { + pname = "terraform-provider-scaleway"; + version = "0.1.1"; + src = { + owner = "terraform-providers"; + repo = "terraform-provider-scaleway"; + rev = "v0.1.1"; + sha256 = "145wfcr5zjjk8vgx5xjf1hqh6h8jqxkhxbvv9x1w34i5bv809ch6"; + }; + }; + tls = + { + pname = "terraform-provider-tls"; + version = "0.1.0"; + src = { + owner = "terraform-providers"; + repo = "terraform-provider-tls"; + rev = "v0.1.0"; + sha256 = "1n1k4dcqm8lp7mgj88xj8xc09mn769np4wg3cggnpcs6igbgdgg7"; + }; + }; + triton = + { + pname = "terraform-provider-triton"; + version = "0.1.2"; + src = { + owner = "terraform-providers"; + repo = "terraform-provider-triton"; + rev = "v0.1.2"; + sha256 = "1jyrmc7932w7d8q96lmd0axf32psfic5d7hmwm1a25vzjzfn9nlw"; + }; + }; + ultradns = + { + pname = "terraform-provider-ultradns"; + version = "0.1.0"; + src = { + owner = "terraform-providers"; + repo = "terraform-provider-ultradns"; + rev = "v0.1.0"; + sha256 = "0bq2y6bxdax7qnmq6vxh8pz9sqy1r3m05dv7q5dbv2xvba1b88hj"; + }; + }; + # Broken with go/src/github.com/terraform-providers/terraform-provider-vsphere/vendor/github.com/hashicorp/terraform/config/testing.go:9: t.Helper undefined (type *testing.T has no field or method Helper) + # vsphere = + # { + # pname = "terraform-provider-vsphere"; + # version = "0.2.1"; + # src = { + # owner = "terraform-providers"; + # repo = "terraform-provider-vsphere"; + # rev = "v0.2.1"; + # sha256 = "04vz34w28nx7j6wlikgjabrb2l5fxj9icfm8d34w2fffz63nk77l"; + # }; + # }; +} diff --git a/pkgs/applications/networking/cluster/terraform/providers/default.nix b/pkgs/applications/networking/cluster/terraform/providers/default.nix new file mode 100644 index 000000000000..df59439c7bf5 --- /dev/null +++ b/pkgs/applications/networking/cluster/terraform/providers/default.nix @@ -0,0 +1,12 @@ +{ stdenv, lib, buildGoPackage, fetchFromGitHub }: +let + list = import ./data.nix; + toDrv = _: data: + buildGoPackage rec { + inherit (data) pname version; + name = "${pname}-${version}"; + goPackagePath = "github.com/${data.src.owner}/${data.src.repo}"; + src = fetchFromGitHub data.src; + }; +in + lib.mapAttrs toDrv list diff --git a/pkgs/applications/networking/cluster/terraform/providers/google.nix b/pkgs/applications/networking/cluster/terraform/providers/google.nix deleted file mode 100644 index 0f8ad21bb13a..000000000000 --- a/pkgs/applications/networking/cluster/terraform/providers/google.nix +++ /dev/null @@ -1,16 +0,0 @@ -{ stdenv, lib, buildGoPackage, fetchFromGitHub }: - -buildGoPackage rec { - pname = "terraform-provider-google"; - name = "${pname}-${version}"; - version = "0.1.3"; - - goPackagePath = "github.com/terraform-providers/terraform-provider-google"; - - src = fetchFromGitHub { - owner = "terraform-providers"; - repo = pname; - rev = "v${version}"; - sha256 = "1aa1hz0yc4g746m6dl04hc70rcrzx0py8kpdch3kim475bspclnf"; - }; -} \ No newline at end of file diff --git a/pkgs/applications/networking/cluster/terraform/providers/kubernetes.nix b/pkgs/applications/networking/cluster/terraform/providers/kubernetes.nix deleted file mode 100644 index 6a8bc8902b6b..000000000000 --- a/pkgs/applications/networking/cluster/terraform/providers/kubernetes.nix +++ /dev/null @@ -1,16 +0,0 @@ -{ stdenv, lib, buildGoPackage, fetchFromGitHub }: - -buildGoPackage rec { - pname = "terraform-provider-kubernetes"; - name = "${pname}-${version}"; - version = "1.0.0"; - - goPackagePath = "github.com/terraform-providers/terraform-provider-kubernetes"; - - src = fetchFromGitHub { - owner = "terraform-providers"; - repo = pname; - rev = "v${version}"; - sha256 = "1kh7a83f98v6b4v3zj84ddhrg2hya4nmvrw0mjc26q12g4z2d5g6"; - }; -} \ No newline at end of file diff --git a/pkgs/applications/networking/cluster/terraform/providers/update-all b/pkgs/applications/networking/cluster/terraform/providers/update-all new file mode 100755 index 000000000000..42c55a4c19d8 --- /dev/null +++ b/pkgs/applications/networking/cluster/terraform/providers/update-all @@ -0,0 +1,82 @@ +#!/usr/bin/env nix-shell +#! nix-shell -i bash -p bash coreutils curl jq nix +# vim: ft=sh sw=2 et +# +# This scripts scans the github terraform-providers repo for new releases, +# generates the corresponding nix code and finally generates an index of +# all the providers. +set -euo pipefail + +GET() { + local url=$1 + echo "fetching $url" >&2 + curl -#fL "$url" +} + +get_org_repos() { + local org=$1 + GET "https://api.github.com/orgs/$org/repos" | jq -r '.[].name' +} + +get_repo_tags() { + local owner=$1 + local repo=$2 + GET "https://api.github.com/repos/$owner/$repo/git/refs/tags" | \ + jq -r '.[].ref' | \ + cut -d '/' -f 3- | \ + sort --version-sort +} + +prefetch_github() { + local owner=$1 + local repo=$2 + local rev=$3 + nix-prefetch-url --unpack "https://github.com/$owner/$repo/archive/$rev.tar.gz" +} + +echo_entry() { + local owner=$1 + local repo=$2 + local rev=$3 + local sha256=$4 + local version=${3:1} + cat < data.nix + +echo "{" >> data.nix +for repo in $repos; do + echo "*** $repo ***" + name=$(echo "$repo" | cut -d - -f 3-) + last_tag=$(get_repo_tags "$org" "$repo" | tail -1) + last_tag_sha256=$(prefetch_github "$org" "$repo" "$last_tag") + + { + echo " $name =" + echo_entry "$org" "$repo" "$last_tag" "$last_tag_sha256" | indent + } >> data.nix +done +echo "}" >> data.nix + +echo Done.