1{ lib, buildGoModule, fetchFromGitHub, installShellFiles }:
2
3buildGoModule rec {
4 pname = "exoscale-cli";
5 version = "1.69.0";
6
7 src = fetchFromGitHub {
8 owner = "exoscale";
9 repo = "cli";
10 rev = "v${version}";
11 sha256 = "sha256-TPsi03SKlcy6QJ91vtgpDwTD2YMfo2fPgKnbmkZG9NQ=";
12 };
13
14 vendorHash = null;
15
16 nativeBuildInputs = [ installShellFiles ];
17
18 ldflags = [ "-s" "-w" "-X main.version=${version}" "-X main.commit=${src.rev}" ];
19
20 # we need to rename the resulting binary but can't use buildFlags with -o here
21 # because these are passed to "go install" which does not recognize -o
22 postBuild = ''
23 mv $GOPATH/bin/cli $GOPATH/bin/exo
24
25 mkdir -p manpage
26 $GOPATH/bin/docs --man-page
27 rm $GOPATH/bin/docs
28
29 $GOPATH/bin/completion bash
30 $GOPATH/bin/completion zsh
31 rm $GOPATH/bin/completion
32 '';
33
34 postInstall = ''
35 installManPage manpage/*
36 installShellCompletion --cmd exo --bash bash_completion --zsh zsh_completion
37 '';
38
39 meta = {
40 description = "Command-line tool for everything at Exoscale: compute, storage, dns";
41 homepage = "https://github.com/exoscale/cli";
42 license = lib.licenses.asl20;
43 maintainers = with lib.maintainers; [ viraptor ];
44 mainProgram = "exo";
45 };
46}