1{ lib
2, stdenv
3, buildGoModule
4, fetchFromGitHub
5, makeWrapper
6, git
7, installShellFiles
8, testers
9, faas-cli
10}:
11let
12 faasPlatform = platform:
13 let cpuName = platform.parsed.cpu.name; in {
14 "aarch64" = "arm64";
15 "armv7l" = "armhf";
16 "armv6l" = "armhf";
17 }.${cpuName} or cpuName;
18in
19buildGoModule rec {
20 pname = "faas-cli";
21 version = "0.16.4";
22
23 src = fetchFromGitHub {
24 owner = "openfaas";
25 repo = "faas-cli";
26 rev = version;
27 sha256 = "sha256-NKKkHn49nbnSirCHUEetn5qJN9r3Sp5aOJ+fWGi45xw=";
28 };
29
30 vendorHash = null;
31
32 CGO_ENABLED = 0;
33
34 subPackages = [ "." ];
35
36 ldflags = [
37 "-s" "-w"
38 "-X github.com/openfaas/faas-cli/version.GitCommit=ref/tags/${version}"
39 "-X github.com/openfaas/faas-cli/version.Version=${version}"
40 "-X github.com/openfaas/faas-cli/commands.Platform=${faasPlatform stdenv.targetPlatform}"
41 ];
42
43 nativeBuildInputs = [ makeWrapper installShellFiles ];
44
45 postInstall = ''
46 wrapProgram "$out/bin/faas-cli" \
47 --prefix PATH : ${lib.makeBinPath [ git ]}
48
49 installShellCompletion --cmd metal \
50 --bash <($out/bin/faas-cli completion --shell bash) \
51 --zsh <($out/bin/faas-cli completion --shell zsh)
52 '';
53
54 passthru.tests.version = testers.testVersion {
55 command = "${faas-cli}/bin/faas-cli version --short-version --warn-update=false";
56 package = faas-cli;
57 };
58
59 meta = with lib; {
60 description = "Official CLI for OpenFaaS ";
61 homepage = "https://github.com/openfaas/faas-cli";
62 license = licenses.mit;
63 maintainers = with maintainers; [ welteki techknowlogick ];
64 };
65}