Auto-updates are enabled on my system, but they’re so very unpredictable. Just now had one running, I was thinking “why is my PC lagging” until you hear a symphony of USB connect/disconnect sounds and you realise, “ohh, it was auto-update”.

So the question is, is there some kind of way to receive a notification when auto-update is running? Preferably with progressbar. Or maybe a way to get notifications when there are updates available? Thanks!

  • balsoft@lemmy.ml
    link
    fedilink
    English
    arrow-up
    2
    ·
    edit-2
    2 months ago

    I think you can do something like this in your config (not tested):

    systemd.services.nixos-upgrade = {
      path = [ pkgs.systemd ];
      serviceConfig.ExecStartPre = pkgs.writeShellScript "nixos-upgrade-notify-start" ''systemd-run --machine <YOUR_USER_NAME>@.host --user ${pkgs.libnotify}/bin/notify-send --urgency critical "System upgrade starting now!"'';
      serviceConfig.ExecStartPost = pkgs.writeShellScript "nixos-upgrade-notify-end" ''systemd-run --machine <YOUR_USER_NAME>@.host --user ${pkgs.libnotify}/bin/notify-send "System upgrade done!"'';
    };
    

    Obviously, replace <YOUR_USER_NAME> with the user you’d like to receive notifications.

    This will send you a notification every time this service starts and finishes.