fix(tailscale): disabled the auto-connect service
This commit is contained in:
		
							parent
							
								
									de551e8393
								
							
						
					
					
						commit
						0b7cd62705
					
				
					 3 changed files with 13 additions and 31 deletions
				
			
		|  | @ -8,47 +8,30 @@ in | |||
| 
 | ||||
| { | ||||
|   config = mkIf cfg.enable { | ||||
| 
 | ||||
|     services.tailscale = { | ||||
|       enable = true; | ||||
|       useRoutingFeatures = mkDefault "both"; | ||||
|       # permitCertUid = "root"; | ||||
|       permitCertUid = "root"; | ||||
|       extraUpFlags = cfg.flags.final; | ||||
|       authKeyFile = "${config.age.secrets.tailscale-auth.path}"; | ||||
|     }; | ||||
| 
 | ||||
|     networking.firewall = { | ||||
|       allowedUDPPorts = [tailscale.port]; | ||||
|       trustedInterfaces = ["${tailscale.interfaceName}"]; | ||||
|       checkReversePath = "loose"; | ||||
|     }; | ||||
| 
 | ||||
|     users = { | ||||
|       groups.tailscaled = {}; | ||||
|       users.tailscaled = { | ||||
|         group = "tailscaled"; | ||||
|         isSystemUser = true; | ||||
|       }; | ||||
|     }; | ||||
|     systemd.network.wait-online.ignoredInterfaces = ["${tailscale.interfaceName}"]; | ||||
| 
 | ||||
|     environment.systemPackages = [ pkgs.tailscale ]; | ||||
| 
 | ||||
|     # disable tailscale logging | ||||
|     systemd.services.tailscaled.serviceConfig.Environment = mkBefore ["TS_NO_LOGS_NO_SUPPORT"]; | ||||
| 
 | ||||
|     systemd.services.tailscale-autoconnect = mkIf cfg.autoconnect { | ||||
|       description = "Automatic connection to Tailscale"; | ||||
| 
 | ||||
|       after = [ "network-pre.target" "tailscale.service" ]; | ||||
|       wants = [ "network-pre.target" "tailscale.service" ]; | ||||
|       wantedBy = [ "multi-user.target" ]; | ||||
| 
 | ||||
|       serviceConfig.Type = "oneshot"; | ||||
| 
 | ||||
|       script = /* bash */ '' | ||||
|         sleep 2 | ||||
| 
 | ||||
|         status="$(${tailscale.package}/bin/tailscale status -json | ${pkgs.jq}/bin/jq -r .BackendState)" | ||||
| 
 | ||||
|         if [ $status = "Running" ]; then | ||||
|           exit 0 | ||||
|         fi | ||||
| 
 | ||||
|         ${tailscale.package}/bin/tailscale up ${toString tailscale.extraUpFlags} | ||||
|       ''; | ||||
|     }; | ||||
|   }; | ||||
| } | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue