diff --git a/flake.nix b/flake.nix
index 2da4404..e6df197 100644
--- a/flake.nix
+++ b/flake.nix
@@ -122,6 +122,13 @@
hash = "sha256-eyvz7XbZKUVQZdSVmDmYlHQSCKFE23OeIH4N4hNDg3M=";
};
vendorHash = "sha256-nwNDuE76fVncegDKI/Fztpc30NX8/shNbSfzkrwTPDk=";
+ # On SIGTERM, Lima's hostagent gracefully powers off the guest and
+ # waits up to 30s for it to halt (pkg/driver/vz/vz_driver_darwin.go).
+ # But its autostart plists set no ExitTimeOut, so launchd's 5s default
+ # SIGKILLs the hostagent when the Mac shuts down --- force-killing the
+ # guest mid-flush, which corrupts Git repos and drops recent writes.
+ # Give the graceful stop room to finish (>= the driver's 30s timeout).
+ patches = (old.patches or [ ]) ++ [ ./lima-exit-timeout.patch ];
});
})
];
diff --git a/lima-exit-timeout.patch b/lima-exit-timeout.patch
new file mode 100644
index 0000000..20dbbbc
--- /dev/null
+++ b/lima-exit-timeout.patch
@@ -0,0 +1,24 @@
+diff --git a/pkg/autostart/launchd/io.lima-vm.autostart.INSTANCE.plist b/pkg/autostart/launchd/io.lima-vm.autostart.INSTANCE.plist
+index 0e777962..15c62d29 100644
+--- a/pkg/autostart/launchd/io.lima-vm.autostart.INSTANCE.plist
++++ b/pkg/autostart/launchd/io.lima-vm.autostart.INSTANCE.plist
+@@ -25,5 +25,7 @@
+ {{ .WorkDir }}
+ ProcessType
+ Background
++ ExitTimeOut
++ 60
+
+
+diff --git a/pkg/autostart/launchd/io.lima-vm.daemon.INSTANCE.plist b/pkg/autostart/launchd/io.lima-vm.daemon.INSTANCE.plist
+index 2da849eb..5af817c9 100644
+--- a/pkg/autostart/launchd/io.lima-vm.daemon.INSTANCE.plist
++++ b/pkg/autostart/launchd/io.lima-vm.daemon.INSTANCE.plist
+@@ -27,5 +27,7 @@
+ {{ .WorkDir }}
+ ProcessType
+ Background
++ ExitTimeOut
++ 60
+
+