nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 buildGoModule,
4 fetchFromGitHub,
5 stdenv,
6 installShellFiles,
7 nix-update-script,
8}:
9
10buildGoModule rec {
11 pname = "globalping-cli";
12 version = "1.5.1";
13
14 src = fetchFromGitHub {
15 owner = "jsdelivr";
16 repo = "globalping-cli";
17 rev = "v${version}";
18 hash = "sha256-muWhiKqPdNVhy7c7MSRHACGzOn5pIVRdqSdfdCJw2CA=";
19 };
20
21 vendorHash = "sha256-dJAuN5srL5EvMaRg8rHaTsurjYrdH45p965DeubpB0E=";
22
23 nativeBuildInputs = [ installShellFiles ];
24
25 env.CGO_ENABLED = 0;
26 subPackages = [ "." ];
27 ldflags = [
28 "-s"
29 "-w"
30 "-X main.version=${version}"
31 ];
32
33 preCheck = ''
34 export HOME="$TMPDIR"
35 '';
36
37 checkFlags =
38 let
39 skippedTests = [
40 # Skip tests that require network access
41 "Test_Authorize"
42 "Test_TokenIntrospection"
43 "Test_Logout"
44 "Test_RevokeToken"
45 "Test_Limits"
46 "Test_CreateMeasurement"
47 "Test_GetMeasurement"
48 ];
49 in
50 [ "-skip=^${builtins.concatStringsSep "|^" skippedTests}" ];
51
52 postInstall = ''
53 mv $out/bin/globalping-cli $out/bin/globalping
54 ''
55 + lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) ''
56 installShellCompletion --cmd globalping \
57 --bash <($out/bin/globalping completion bash) \
58 --fish <($out/bin/globalping completion fish) \
59 --zsh <($out/bin/globalping completion zsh)
60 '';
61
62 passthru.updateScript = nix-update-script { };
63
64 meta = {
65 description = "Simple CLI tool to run networking commands remotely from hundreds of globally distributed servers";
66 homepage = "https://www.jsdelivr.com/globalping/cli";
67 license = lib.licenses.mpl20;
68 maintainers = with lib.maintainers; [ xyenon ];
69 mainProgram = "globalping";
70 };
71}