1{
2 lib,
3 buildGoModule,
4 fetchFromGitHub,
5 stdenv,
6 nix-update-script,
7 buildPackages,
8 installShellFiles,
9 versionCheckHook,
10}:
11buildGoModule (finalAttrs: {
12 pname = "usque";
13 version = "1.4.1";
14 src = fetchFromGitHub {
15 owner = "Diniboy1123";
16 repo = "usque";
17 tag = "v${finalAttrs.version}";
18 hash = "sha256-/4/hsoWGdNe5vF22hFXuItXlYiLZ5BKrfg5XSFyljhE=";
19 };
20
21 vendorHash = "sha256-ngLlG9HP0KJPjIBVsNZuwnlJj2egMEh9U0xVQpVEg1Q=";
22
23 ldflags = [
24 "-s"
25 "-w"
26 "-X github.com/Diniboy1123/usque/cmd.version=${finalAttrs.version}"
27 ];
28 nativeBuildInputs = [ installShellFiles ];
29 postInstall =
30 let
31 exe =
32 if stdenv.buildPlatform.canExecute stdenv.hostPlatform then
33 "$out/bin/usque"
34 else
35 lib.getExe buildPackages.usque;
36 in
37 ''
38 installShellCompletion --cmd usque \
39 --bash <(${exe} completion bash) \
40 --fish <(${exe} completion fish) \
41 --zsh <(${exe} completion zsh)
42 '';
43
44 nativeInstallCheckInputs = [
45 versionCheckHook
46 ];
47 doInstallCheck = true;
48 versionCheckProgram = "${placeholder "out"}/bin/${finalAttrs.meta.mainProgram}";
49 versionCheckProgramArg = "version";
50
51 passthru.updateScript = nix-update-script { };
52
53 meta = {
54 mainProgram = "usque";
55 maintainers = with lib.maintainers; [ xddxdd ];
56 description = "Open-source reimplementation of the Cloudflare WARP client's MASQUE protocol";
57 homepage = "https://github.com/Diniboy1123/usque";
58 license = lib.licenses.mit;
59 changelog = "https://github.com/Diniboy1123/usque/releases/tag/v${finalAttrs.version}";
60 };
61})