about summary refs log tree commit diff
path: root/pkgs/development/tools/faas-cli/default.nix
blob: 3978737cf5820d9e4f8636eab303b6e22e3ced07 (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
{ lib
, stdenv
, buildGoModule
, fetchFromGitHub
, makeWrapper
, git
, installShellFiles
, testers
, faas-cli
}:
let
  faasPlatform = platform:
    let cpuName = platform.parsed.cpu.name; in {
      "aarch64" = "arm64";
      "armv7l" = "armhf";
      "armv6l" = "armhf";
    }.${cpuName} or cpuName;
in
buildGoModule rec {
  pname = "faas-cli";
  version = "0.16.31";

  src = fetchFromGitHub {
    owner = "openfaas";
    repo = "faas-cli";
    rev = version;
    sha256 = "sha256-RvDrdgHzGGjJorm55ksMk+YqPdBgQyWs1IDaxqOYON8=";
  };

  vendorHash = null;

  CGO_ENABLED = 0;

  subPackages = [ "." ];

  ldflags = [
    "-s" "-w"
    "-X github.com/openfaas/faas-cli/version.GitCommit=ref/tags/${version}"
    "-X github.com/openfaas/faas-cli/version.Version=${version}"
    "-X github.com/openfaas/faas-cli/commands.Platform=${faasPlatform stdenv.hostPlatform}"
  ];

  nativeBuildInputs = [ makeWrapper installShellFiles ];

  postInstall = ''
    wrapProgram "$out/bin/faas-cli" \
      --prefix PATH : ${lib.makeBinPath [ git ]}

    installShellCompletion --cmd metal \
      --bash <($out/bin/faas-cli completion --shell bash) \
      --zsh <($out/bin/faas-cli completion --shell zsh)
  '';

  passthru.tests.version = testers.testVersion {
    command = "${faas-cli}/bin/faas-cli version --short-version --warn-update=false";
    package = faas-cli;
  };

  meta = with lib; {
    description = "Official CLI for OpenFaaS";
    mainProgram = "faas-cli";
    homepage = "https://github.com/openfaas/faas-cli";
    license = licenses.mit;
    maintainers = with maintainers; [ welteki techknowlogick ];
  };
}