Skip to content

system.autoUpgrade.* Functionality #253

@commiterate

Description

@commiterate

Is your feature request related to a problem? Please describe.

Users currently need to add their own auto-update infrastructure to periodically update non-NixOS Linux machines managed with system-manager.

It would be convenient if system-manager could auto-create systemd units which periodically do a system-manager switch.

Describe the solution you'd like

NixOS has system.autoUpgrade.* options which create a systemd timer that periodically runs nixos-rebuild switch.

The idea is to support most of the same system.autoUpgrade.* options (maybe not the reboot ones since system-manager doesn't manage the kernel or initrd yet) but generate a systemd timer which runs system-manager switch instead of nixos-rebuild switch.

Describe alternatives you've considered

Writing the unit files manually outside of system-manager essentially equivalent to the below NixOS module but without the special NixOS systemd unit configurations controlling unit removal/update behavior.

{
  lib,
  pkgs,
  ...
}:
{
  config = {
    systemd = {
      services = {
        system-manager-upgrade = {
          description = "system-manager Upgrade";
          after = [
            "network-online.target"
          ];
          wants = [
            "network-online.target"
          ];
          unitConfig = {
            X-StopOnRemoval = false;
          };
          serviceConfig = {
            X-RestartIfChanged = false;
            Type = "oneshot";
            ExecStart = "${lib.meta.getExe system-manager} switch --flake {flake URI} --refresh";
          };
        };
      };

      timers = {
        system-manager-upgrade = {
          timerConfig = {
            FixedRandomDelay = false;
            OnCalendar = "daily";
            Persistent = true;
            RandomizedDelaySec = 0;
          };
        };
      };
    };
  };
}

I think these units currently can't be managed by system-manager since it doesn't handle the special lifecycle attributes.

Additional context

Likely needs #129 to be addressed first to add a --refresh flag to system-manager commands (forcefully re-resolve Git references like refs/heads/main).

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions