system.autoUpgrade not waiting for network after standby

I’ve successfully brought system.autoUpgrade to work perfectly on my Laptops, and it could be all so perfect and fine…
But then there is this one issue left: If I have my laptop in standby, the Wifi connection will not be there immediately after I power it back on. autoUpgrade starts immediately and runs into an issue (persistent is set to true), only to be deactivated until the next week…
Workaround would be to execute the autoUpgrade much more often, but that doesn’t seem like a great option either. Is there something I just don’t see here?

I found this too when I first setup autoUpgrade. I added a preStart item to the unit file that checks for network connectivity, waits a couple of minutes, then tries again.

  system.autoUpgrade = {
    enable = true;
    flake = "${flakePath}#${config.networking.hostName}";
    flags = [
    dates = "04:40";
    persistent = true;
    randomizedDelaySec = "45min";
  # Allow nixos-upgrade to restart on failure (e.g. when laptop wakes up before network connection is set) = {
    preStart = "${}/bin/host";  # Check network connectivity
    serviceConfig = {
      Restart = "on-failure";
      RestartSec = "120";
    unitConfig = {
      StartLimitIntervalSec = 600;
      StartLimitBurst = 2;
    after = ["flake-update.service"];
    wants = ["flake-update.service"];
    path = [];

Hope that helps!

1 Like

That looks exactly like what I need, thank you very much! I didn’t know that I could do that to the systemd service, so this answer will enable me to do a lot more in the future, AWESOME!!!