lol
1{
2 lib,
3 stdenv,
4 buildGoModule,
5 fetchFromGitHub,
6 testers,
7 flyctl,
8 installShellFiles,
9}:
10
11buildGoModule rec {
12 pname = "flyctl";
13 version = "0.3.172";
14
15 src = fetchFromGitHub {
16 owner = "superfly";
17 repo = "flyctl";
18 rev = "v${version}";
19 hash = "sha256-jKzlKOdE+SrCzY81ciI9sKN0iiFZMsKp04A+1TV1+i0=";
20 };
21
22 vendorHash = "sha256-D6b+dLoE4IdhsmnWILe7Thkggq3p0ur4C3BOz7Cuk98=";
23
24 subPackages = [ "." ];
25
26 ldflags = [
27 "-s"
28 "-w"
29 "-X github.com/superfly/flyctl/internal/buildinfo.buildDate=1970-01-01T00:00:00Z"
30 "-X github.com/superfly/flyctl/internal/buildinfo.buildVersion=${version}"
31 ];
32 tags = [ "production" ];
33
34 nativeBuildInputs = [ installShellFiles ];
35
36 patches = [ ./disable-auto-update.patch ];
37
38 preBuild = ''
39 GOOS= GOARCH= CGO_ENABLED=0 go generate ./...
40 '';
41
42 preCheck = ''
43 HOME=$(mktemp -d)
44 '';
45
46 # We override checkPhase to be able to test ./... while using subPackages
47 checkPhase = ''
48 runHook preCheck
49 # We do not set trimpath for tests, in case they reference test assets
50 export GOFLAGS=''${GOFLAGS//-trimpath/}
51
52 buildGoDir test ./...
53
54 runHook postCheck
55 '';
56
57 postInstall = lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) ''
58 installShellCompletion --cmd flyctl \
59 --bash <($out/bin/flyctl completion bash) \
60 --fish <($out/bin/flyctl completion fish) \
61 --zsh <($out/bin/flyctl completion zsh)
62 ln -s $out/bin/flyctl $out/bin/fly
63 '';
64
65 passthru.tests.version = testers.testVersion {
66 package = flyctl;
67 command = "HOME=$(mktemp -d) flyctl version";
68 version = "v${flyctl.version}";
69 };
70
71 meta = {
72 description = "Command line tools for fly.io services";
73 downloadPage = "https://github.com/superfly/flyctl";
74 homepage = "https://fly.io/";
75 license = lib.licenses.asl20;
76 maintainers = with lib.maintainers; [
77 adtya
78 jsierles
79 techknowlogick
80 RaghavSood
81 ];
82 mainProgram = "flyctl";
83 };
84}