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