summary refs log tree commit diff
path: root/pkgs/servers/consul/default.nix
blob: 9244ee2f2cf592b6b8b8a6ffc08ec913914f098f (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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
{ stdenv, lib, go, fetchgit, fetchhg, fetchbzr, fetchFromGitHub
, ruby, rubyLibs, nodejs }:

let
  version = "0.4.0";
in

with lib;
stdenv.mkDerivation {
  name = "consul-${version}";

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

  buildInputs = [ go ruby rubyLibs.sass nodejs ];

  configurePhase = flip concatMapStrings
    (with rubyLibs; [ execjs json minitest rake rdoc sass uglifier ])
    (gem: ''
      export GEM_PATH="$GEM_PATH:${gem}/${ruby.gemPath}"
    '');

  buildPhase = ''
    # Build consul binary
    export GOPATH=$src
    go build -v -o consul github.com/hashicorp/consul

    # Build ui static files
    ({
      cp -r src/github.com/hashicorp/consul/ui .
      cd ui
      chmod -R u+w .
      make dist
    })
  '';

  outputs = [ "out" "ui" ];

  installPhase = ''
    # Install consul binary
    mkdir -p $out/bin
    cp consul $out/bin

    # Install ui static files
    mkdir -p $ui
    mv ui/dist/* $ui
  '';

  meta = with lib; {
    homepage    = http://www.consul.io/;
    description = "A tool for service discovery, monitoring and configuration";
    maintainers = with maintainers; [ cstrahan wkennington ];
    license     = licenses.mpl20 ;
    platforms   = platforms.unix;
  };
}