From f68fcce055473cf90913a99f29589ab11cc1088f Mon Sep 17 00:00:00 2001
From: matt1432 <matt@nelim.org>
Date: Mon, 10 Feb 2025 12:54:06 -0500
Subject: [PATCH] fix(homie): add temp fix for losing internet

---
 configurations/homie/default.nix | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/configurations/homie/default.nix b/configurations/homie/default.nix
index e4f6a163..7c8eb0fc 100644
--- a/configurations/homie/default.nix
+++ b/configurations/homie/default.nix
@@ -1,5 +1,6 @@
 {
   mainUser,
+  pkgs,
   self,
   ...
 }: {
@@ -38,6 +39,30 @@
     firewall.enable = false;
   };
 
+  # FIXME: temporary fix while I figure out the issue with the Network Card?
+  systemd.services."temp-fix-nic" = {
+    wantedBy = ["multi-user.target"];
+    after = ["tailscaled.service"];
+    path = [pkgs.ripgrep];
+    script = ''
+      # Wait for boot to finish
+      sleep 60
+
+      echo "start listening to journalctl"
+
+      journalctl -fb | while read -r line; do
+          if echo "$line" | rg 'NIC Link is Up' &> /dev/null; then
+              echo "restarting tailscaled"
+              systemctl restart tailscaled.service
+          fi
+      done
+    '';
+    serviceConfig = {
+      User = "root";
+      AmbientCapabilities = "CAP_SYS_ADMIN CAP_SYSLOG";
+    };
+  };
+
   time.timeZone = "America/Montreal";
 
   # ------------------------------------------------