summary refs log tree commit diff
path: root/pkgs/servers/consul/template.nix
blob: 59ca524b51e32bf071b6486afad37ba6f332519b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
{ stdenv, lib, go, fetchgit, fetchhg, fetchbzr, fetchFromGitHub }:

stdenv.mkDerivation rec {
  name = "consul-template-${version}";
  version = "0.7.0";

  src = import ./deps.nix {
    inherit stdenv lib fetchgit fetchhg fetchbzr fetchFromGitHub;
  };

  buildInputs = [ go ];

  buildPhase = ''
    GOPATH=$src go build -v -o consul-template github.com/hashicorp/consul-template
  '';

  installPhase = ''
    # Fix references to go-deps in the binary
    hash=$(echo $src | sed 's,.*/\([^/-]*\).*,\1,g')
    xs=$(printf 'x%.0s' $(seq 2 $(echo $hash | wc -c)))
    sed -i "s,$hash,$xs,g" consul-template

    mkdir -p $out/bin
    cp consul-template $out/bin
  '';

  meta = with lib; {
    description = "Generic template rendering and notifications with Consul";
    homepage = https://github.com/hashicorp/consul-template;
    license = licenses.mpl20;
    maintainers = with maintainers; [ puffnfresh wkennington ];
    platforms = platforms.unix;
  };
}