From 0ae311e1c74ad88a74b3ee5d897d4df4f633044f Mon Sep 17 00:00:00 2001 From: Michael Hoang Date: Tue, 20 Sep 2022 16:09:02 +1000 Subject: [PATCH] tailscale: fix `tailscaled` not running as root Run `tailscaled` using a system daemon as it does not work as a non-root user without `userspace-networking`. Also, remove the broken warning relating to setting the search domain. Manually adding the search domain to `networking.search` isn't necessary to use only machine names to refer to other machines. --- modules/services/tailscale.nix | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/modules/services/tailscale.nix b/modules/services/tailscale.nix index fb63af9..201e04a 100644 --- a/modules/services/tailscale.nix +++ b/modules/services/tailscale.nix @@ -29,20 +29,21 @@ in }; config = mkIf cfg.enable { - warnings = [ - (mkIf (cfg.magicDNS.enable && cfg.domain == "") "${showOption cfg.domain} isn't empty, Tailscale MagicDNS search path won't be configured.") - ]; - environment.systemPackages = [ cfg.package ]; - launchd.user.agents.tailscaled = { + + launchd.daemons.tailscaled = { # derived from # https://github.com/tailscale/tailscale/blob/main/cmd/tailscaled/install_darwin.go#L30 serviceConfig = { Label = "com.tailscale.tailscaled"; - ProgramArguments = [ "${lib.getBin cfg.package}/bin/tailscaled" ]; + ProgramArguments = [ + "/bin/sh" "-c" + "/bin/wait4path ${cfg.package} && ${cfg.package}/bin/tailscaled" + ]; RunAtLoad = true; }; }; + networking = mkIf cfg.magicDNS.enable { dns = [ "100.100.100.100" ]; search =