From 0d14c3cc5b94aceef28f1991ae7ef2f973e43bd2 Mon Sep 17 00:00:00 2001 From: Arnout Engelen Date: Tue, 20 May 2025 22:16:12 +0200 Subject: [PATCH] nixos: autoUpgrade: allow disabling flake upgrades When auto-upgrading based on a flake, it might be desirable to only upgrade to the newer flake, without updating the nixpkgs from the flake lock. This option makes that possible. --- nixos/modules/tasks/auto-upgrade.nix | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/nixos/modules/tasks/auto-upgrade.nix b/nixos/modules/tasks/auto-upgrade.nix index 0d3756a772f4..4effda9ef4cd 100644 --- a/nixos/modules/tasks/auto-upgrade.nix +++ b/nixos/modules/tasks/auto-upgrade.nix @@ -61,6 +61,16 @@ in ''; }; + upgrade = lib.mkOption { + type = lib.types.bool; + default = true; + description = '' + Disable adding the `--upgrade` parameter when `channel` + is not set, such as when upgrading to the latest version + of a flake honouring its lockfile. + ''; + }; + flags = lib.mkOption { type = lib.types.listOf lib.types.str; default = [ ]; @@ -235,7 +245,7 @@ in date = "${pkgs.coreutils}/bin/date"; readlink = "${pkgs.coreutils}/bin/readlink"; shutdown = "${config.systemd.package}/bin/shutdown"; - upgradeFlag = lib.optional (cfg.channel == null) "--upgrade"; + upgradeFlag = lib.optional (cfg.channel == null && cfg.upgrade) "--upgrade"; in if cfg.allowReboot then ''