8 cfg = config.services.cloudflare-warp;
11 options.services.cloudflare-warp = {
12 enable = lib.mkEnableOption "Cloudflare Zero Trust client daemon";
14 package = lib.mkPackageOption pkgs "cloudflare-warp" { };
16 rootDir = lib.mkOption {
18 default = "/var/lib/cloudflare-warp";
20 Working directory for the warp-svc daemon.
24 udpPort = lib.mkOption {
25 type = lib.types.port;
28 The UDP port to open in the firewall. Warp uses port 2408 by default, but fallback ports can be used
29 if that conflicts with another service. See the [firewall documentation](https://developers.cloudflare.com/cloudflare-one/connections/connect-devices/warp/deployment/firewall#warp-udp-ports)
30 for the pre-configured available fallback ports.
34 openFirewall = lib.mkEnableOption "opening UDP ports in the firewall" // {
39 config = lib.mkIf cfg.enable {
40 environment.systemPackages = [ cfg.package ];
42 networking.firewall = lib.mkIf cfg.openFirewall {
43 allowedUDPPorts = [ cfg.udpPort ];
46 systemd.tmpfiles.rules = [
47 "d ${cfg.rootDir} - root root"
48 "z ${cfg.rootDir} - root root"
51 systemd.services.cloudflare-warp = {
53 description = "Cloudflare Zero Trust Client Daemon";
55 # lsof is used by the service to determine which UDP port to bind to
56 # in the case that it detects collisions.
58 requires = [ "network.target" ];
59 wantedBy = [ "multi-user.target" ];
65 "CAP_NET_BIND_SERVICE"
71 ExecStart = "${cfg.package}/bin/warp-svc";
76 CapabilityBoundingSet = caps;
77 AmbientCapabilities = caps;
80 Environment = [ "RUST_BACKTRACE=full" ];
81 WorkingDirectory = cfg.rootDir;
83 # See the systemd.exec docs for the canonicalized paths, the service
84 # makes use of them for logging, and account state info tracking.
85 # https://www.freedesktop.org/software/systemd/man/latest/systemd.exec.html#RuntimeDirectory=
86 StateDirectory = "cloudflare-warp";
87 RuntimeDirectory = "cloudflare-warp";
88 LogsDirectory = "cloudflare-warp";
90 # The service needs to write to /etc/resolv.conf to configure DNS, so that file would have to
91 # be world read/writable to run as anything other than root.
98 meta.maintainers = with lib.maintainers; [ treyfortmuller ];