From 799cdbd8342c5ad3adbede25caf6d544c56f019b Mon Sep 17 00:00:00 2001 From: Profpatsch Date: Fri, 4 Jun 2021 22:18:59 +0200 Subject: [PATCH] tailscale: add `interfaceName` option MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- nixos/modules/services/networking/tailscale.nix | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/nixos/modules/services/networking/tailscale.nix b/nixos/modules/services/networking/tailscale.nix index 9a28a266a928..c33a38179ee4 100644 --- a/nixos/modules/services/networking/tailscale.nix +++ b/nixos/modules/services/networking/tailscale.nix @@ -15,6 +15,12 @@ in { description = "The port to listen on for tunnel traffic (0=autoselect)."; }; + interfaceName = mkOption { + type = types.str; + default = "tailscale0"; + description = ''The interface name for tunnel traffic. Use "userspace-networking" (beta) to not use TUN.''; + }; + package = mkOption { type = types.package; default = pkgs.tailscale; @@ -29,7 +35,10 @@ in { systemd.services.tailscaled = { wantedBy = [ "multi-user.target" ]; path = [ pkgs.openresolv ]; - serviceConfig.Environment = "PORT=${toString cfg.port}"; + serviceConfig.Environment = [ + "PORT=${toString cfg.port}" + ''"FLAGS=--tun ${lib.escapeShellArg cfg.interfaceName}"'' + ]; }; }; }