From 8457d9277a5346360480eeeb9319567ad94fe1e7 Mon Sep 17 00:00:00 2001 From: Alexandre Badez Date: Thu, 28 Jul 2022 14:23:52 +0200 Subject: [PATCH] system.autoUpgrade: add boot option. --- nixos/modules/tasks/auto-upgrade.nix | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) 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;