nixpkgs/pkgs/applications/networking/cluster/terraform-providers/default.nix
Marius Bergmann 3ddd53e576 terraform-providers: fix handling of version/rev in provider list
I interpreted the purpose of stripping the first character from the 'version'
argument as an attempt to remove a prefixed 'v' (e.g. 'v1.0.0') from a version
tag. This works if the tag actually has a 'v' prefix, but also removes the first
character if version tags are not prefixed (e.g. '1.0.0').

Additionally, the 'v' was added again when specifying the `rev` for
`fetchFromGitHub` in default.nix. As described above, this did also not work
when provider repos did not prefix their version tags with 'v'.

I changed the implementation as follows:

- `version` and `rev` are stored inside data.nix
- `version` is used to declare the nix package version
- `rev` is used to fetch the proper git ref when building the package
- for determining `version`, an optional leading 'v' is trimmed from the tag
  name

Now this has the implication that the latest tag must always be a release tag
when using the `update-all` script, but as the result of running `update-all`
should always be reviewed before submission, makes this appear a manageable
tradeoff to me.
2019-11-08 23:41:08 +01:00

38 lines
1.5 KiB
Nix

{ lib
, buildGoPackage
, fetchFromGitHub
, callPackage
, buildGo112Module
}:
let
list = import ./data.nix;
toDrv = data:
buildGoPackage rec {
inherit (data) owner repo rev version sha256;
name = "${repo}-${version}";
goPackagePath = "github.com/${owner}/${repo}";
subPackages = [ "." ];
src = fetchFromGitHub {
inherit owner repo rev sha256;
};
# Terraform allow checking the provider versions, but this breaks
# if the versions are not provided via file paths.
postBuild = "mv go/bin/${repo}{,_v${version}}";
};
in
{
elasticsearch = callPackage ./elasticsearch {
# Version 0.7.0 fails to build with go 1.13 due to dependencies:
# verifying git.apache.org/thrift.git@v0.12.0/go.mod: git.apache.org/thrift.git@v0.12.0/go.mod: Get https://sum.golang.org/lookup/git.apache.org/thrift.git@v0.12.0: dial tcp: lookup sum.golang.org on [::1]:53: read udp [::1]:52968->[::1]:53: read: connection refused
# verifying github.com/hashicorp/terraform@v0.12.0/go.mod: github.com/hashicorp/terraform@v0.12.0/go.mod: Get https://sum.golang.org/lookup/github.com/hashicorp/terraform@v0.12.0: dial tcp: lookup sum.golang.org on [::1]:53: read udp [::1]:52968->[::1]:53: read: connection refused
buildGoModule = buildGo112Module;
};
gandi = callPackage ./gandi {};
ibm = callPackage ./ibm {};
libvirt = callPackage ./libvirt {};
ansible = callPackage ./ansible {};
} // lib.mapAttrs (n: v: toDrv v) list