From 4bc645061b8c3108fdb3ee92a61dbe3e98ecdaea Mon Sep 17 00:00:00 2001 From: "RingOfStorms (Joshua Bell)" Date: Tue, 6 Jan 2026 16:57:04 -0600 Subject: [PATCH] try to fix tun --- hosts/juni/flake.nix | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/hosts/juni/flake.nix b/hosts/juni/flake.nix index b2534642..92289ab6 100644 --- a/hosts/juni/flake.nix +++ b/hosts/juni/flake.nix @@ -88,6 +88,31 @@ inputs.common.nixosModules.tty_caps_esc inputs.common.nixosModules.zsh inputs.common.nixosModules.tailnet + ( + { pkgs, lib, ... }: + { + # Some boots come up without `/dev/net/tun` until `modprobe tun`. + # This makes `tailscaled` reliable by forcing the module load + # before it starts. + systemd.services.ensure-tun = { + description = "Ensure tun module is loaded"; + wantedBy = [ "tailscaled.service" ]; + before = [ "tailscaled.service" ]; + after = [ "systemd-modules-load.service" ]; + serviceConfig = { + Type = "oneshot"; + RemainAfterExit = true; + ExecStart = "${pkgs.kmod}/bin/modprobe tun"; + }; + }; + + systemd.services.tailscaled = { + after = lib.mkAfter [ "ensure-tun.service" ]; + wants = lib.mkAfter [ "ensure-tun.service" ]; + requires = lib.mkAfter [ "ensure-tun.service" ]; + }; + } + ) inputs.common.nixosModules.remote_lio_builds (