tailscale: add `interfaceName` option

tailscale allows to specify the interface name.
The upstream systemd unit does not expose it directly however, only
via the `FLAGS` environment variable.

I can’t be 100% sure that the escaping is correct, but this is as good
as we can do for now, unless upstream changes their unit file.

+10 -1
+10 -1
nixos/modules/services/networking/tailscale.nix
··· 15 15 description = "The port to listen on for tunnel traffic (0=autoselect)."; 16 16 }; 17 17 18 + interfaceName = mkOption { 19 + type = types.str; 20 + default = "tailscale0"; 21 + description = ''The interface name for tunnel traffic. Use "userspace-networking" (beta) to not use TUN.''; 22 + }; 23 + 18 24 package = mkOption { 19 25 type = types.package; 20 26 default = pkgs.tailscale; ··· 29 35 systemd.services.tailscaled = { 30 36 wantedBy = [ "multi-user.target" ]; 31 37 path = [ pkgs.openresolv ]; 32 - serviceConfig.Environment = "PORT=${toString cfg.port}"; 38 + serviceConfig.Environment = [ 39 + "PORT=${toString cfg.port}" 40 + ''"FLAGS=--tun ${lib.escapeShellArg cfg.interfaceName}"'' 41 + ]; 33 42 }; 34 43 }; 35 44 }