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.
This commit is contained in:
Profpatsch 2021-06-04 22:18:59 +02:00
parent 44c5e2b26d
commit 799cdbd834

View file

@ -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}"''
];
};
};
}