1{
2 lib,
3 stdenv,
4 buildGoModule,
5 fetchFromGitHub,
6 callPackage,
7 gitUpdater,
8}:
9
10buildGoModule rec {
11 pname = "cloudflared";
12 version = "2025.7.0";
13
14 src = fetchFromGitHub {
15 owner = "cloudflare";
16 repo = "cloudflared";
17 tag = version;
18 hash = "sha256-GAmSWdyFQYtGQ5Ml+10Xy7OpKc1bXuAc3hy7Ly6+yC8=";
19 };
20
21 vendorHash = null;
22
23 ldflags = [
24 "-s"
25 "-w"
26 "-X main.Version=${version}"
27 "-X github.com/cloudflare/cloudflared/cmd/cloudflared/updater.BuiltForPackageManager=nixpkgs"
28 ];
29
30 preCheck = ''
31 # Workaround for: sshgen_test.go:74: mkdir /homeless-shelter/.cloudflared: no such file or directory
32 export HOME="$(mktemp -d)"
33
34 # Workaround for: protocol_test.go:11:
35 # lookup protocol-v2.argotunnel.com on [::1]:53: read udp [::1]:51876->[::1]:53: read: connection refused
36 substituteInPlace "edgediscovery/protocol_test.go" \
37 --replace "TestProtocolPercentage" "SkipProtocolPercentage"
38
39 # Workaround for: origin_icmp_proxy_test.go:46:
40 # cannot create ICMPv4 proxy: socket: permission denied nor ICMPv6 proxy: socket: permission denied
41 substituteInPlace "ingress/origin_icmp_proxy_test.go" \
42 --replace "TestICMPRouterEcho" "SkipICMPRouterEcho"
43
44 # Workaround for: origin_icmp_proxy_test.go:110:
45 # cannot create ICMPv4 proxy: socket: permission denied nor ICMPv6 proxy: socket: permission denied
46 substituteInPlace "ingress/origin_icmp_proxy_test.go" \
47 --replace "TestConcurrentRequestsToSameDst" "SkipConcurrentRequestsToSameDst"
48
49 # Workaround for: origin_icmp_proxy_test.go:242:
50 # cannot create ICMPv4 proxy: socket: permission denied nor ICMPv6 proxy: socket: permission denied
51 substituteInPlace "ingress/origin_icmp_proxy_test.go" \
52 --replace "TestICMPRouterRejectNotEcho" "SkipICMPRouterRejectNotEcho"
53
54 # Workaround for: origin_icmp_proxy_test.go:108:
55 # Received unexpected error: cannot create ICMPv4 proxy: Group ID 100 is not between ping group 65534 to 65534 nor ICMPv6 proxy: socket: permission denied
56 substituteInPlace "ingress/origin_icmp_proxy_test.go" \
57 --replace "TestTraceICMPRouterEcho" "SkipTraceICMPRouterEcho"
58
59 # Workaround for: icmp_posix_test.go:28: socket: permission denied
60 substituteInPlace "ingress/icmp_posix_test.go" \
61 --replace "TestFunnelIdleTimeout" "SkipFunnelIdleTimeout"
62
63 # Workaround for: icmp_posix_test.go:88: Received unexpected error: Group ID 100 is not between ping group 65534 to 65534
64 substituteInPlace "ingress/icmp_posix_test.go" \
65 --replace "TestReuseFunnel" "SkipReuseFunnel"
66
67 # Workaround for: manager_test.go:197:
68 # Should be false
69 substituteInPlace "datagramsession/manager_test.go" \
70 --replace "TestManagerCtxDoneCloseSessions" "SkipManagerCtxDoneCloseSessions"
71 '';
72
73 doCheck = !stdenv.hostPlatform.isDarwin;
74
75 passthru = {
76 tests.simple = callPackage ./tests.nix { inherit version; };
77 updateScript = gitUpdater { };
78 };
79
80 meta = {
81 description = "Cloudflare Tunnel daemon, Cloudflare Access toolkit, and DNS-over-HTTPS client";
82 homepage = "https://www.cloudflare.com/products/tunnel";
83 changelog = "https://github.com/cloudflare/cloudflared/releases/tag/${version}";
84 license = lib.licenses.asl20;
85 platforms = lib.platforms.unix ++ lib.platforms.windows;
86 maintainers = with lib.maintainers; [
87 bbigras
88 enorris
89 thoughtpolice
90 piperswe
91 qjoly
92 wrbbz
93 ];
94 mainProgram = "cloudflared";
95 };
96}