summary refs log tree commit diff
path: root/pkgs/applications/networking/cluster/waypoint/default.nix
blob: 038ab2c2bf7f403861395a73b266843e4f399ac2 (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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
{ lib, buildGoModule, fetchFromGitHub, go-bindata, installShellFiles }:

buildGoModule rec {
  pname = "waypoint";
  version = "0.8.2";

  src = fetchFromGitHub {
    owner = "hashicorp";
    repo = pname;
    rev = "v${version}";
    sha256 = "sha256-Pq1gGXROPHHMaOoQwx6cObvMF+SoilOROR4bwI0Y/GM=";
  };

  vendorSha256 = "sha256-Q8ookgQwecRuSrnQiIREBMDxK9NAWfHu+sIQeMO/T4w=";

  nativeBuildInputs = [ go-bindata installShellFiles ];

  # GIT_{COMMIT,DIRTY} filled in blank to prevent trying to run git and ending up blank anyway
  buildPhase = ''
    runHook preBuild
    make bin GIT_DESCRIBE="v${version}" GIT_COMMIT="" GIT_DIRTY=""
    runHook postBuild
  '';

  doCheck = false;

  installPhase = ''
    runHook preInstall

    local INSTALL="$out/bin/waypoint"
    install -D waypoint $out/bin/waypoint

    # waypoint's completion install command alters your <something>rc files
    # below is the equivalent of what it injects

    # Write to a file as it doesn't like EOF within <()
    cat > waypoint.fish <<EOF
    function __complete_waypoint
      set -lx COMP_LINE (commandline -cp)
      test -z (commandline -ct)
      and set COMP_LINE "$COMP_LINE "
      $INSTALL
    end
    complete -f -c waypoint -a "(__complete_waypoint)"
    EOF
    installShellCompletion --cmd waypoint \
      --bash <(echo "complete -C $INSTALL waypoint") \
      --fish <(cat waypoint.fish) \
      --zsh <(echo "complete -o nospace -C $INSTALL waypoint")

    runHook postInstall
  '';

  doInstallCheck = true;
  installCheckPhase = ''
    runHook preInstallCheck
    # `version` tries to write to ~/.config/waypoint
    export HOME="$TMPDIR"

    $out/bin/waypoint --help
    $out/bin/waypoint version | grep "CLI: v${version}"
    runHook postInstallCheck
  '';

  # Binary is static
  dontPatchELF = true;
  dontPatchShebangs = true;

  meta = with lib; {
    homepage = "https://waypointproject.io";
    changelog = "https://github.com/hashicorp/waypoint/blob/v${version}/CHANGELOG.md";
    description = "A tool to build, deploy, and release any application on any platform";
    longDescription = ''
      Waypoint allows developers to define their application build, deploy, and
      release lifecycle as code, reducing the time to deliver deployments
      through a consistent and repeatable workflow.
    '';
    license = licenses.mpl20;
    maintainers = with maintainers; [ winpat jk techknowlogick ];
  };
}