diff --git a/nixos/modules/tasks/auto-upgrade.nix b/nixos/modules/tasks/auto-upgrade.nix
index 21a25cbfa964..54eee19dc771 100644
--- a/nixos/modules/tasks/auto-upgrade.nix
+++ b/nixos/modules/tasks/auto-upgrade.nix
@@ -21,6 +21,17 @@ in {
'';
};
+ operation = mkOption {
+ type = types.enum ["switch" "boot"];
+ default = "switch";
+ example = "boot";
+ description = ''
+ Whether to run
+ nixos-rebuild switch --upgrade or run
+ nixos-rebuild boot --upgrade
+ '';
+ };
+
flake = mkOption {
type = types.nullOr types.str;
default = null;
@@ -223,7 +234,7 @@ in {
''}
if [ "''${booted}" = "''${built}" ]; then
- ${nixos-rebuild} switch ${toString cfg.flags}
+ ${nixos-rebuild} ${cfg.operation} ${toString cfg.flags}
${optionalString (cfg.rebootWindow != null) ''
elif [ "''${do_reboot}" != true ]; then
echo "Outside of configured reboot window, skipping."
@@ -232,7 +243,7 @@ in {
${shutdown} -r +1
fi
'' else ''
- ${nixos-rebuild} switch ${toString (cfg.flags ++ upgradeFlag)}
+ ${nixos-rebuild} ${cfg.operation} ${toString (cfg.flags ++ upgradeFlag)}
'';
startAt = cfg.dates;