summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorquentin@aristote.fr <quentin@aristote.fr>2025-01-29 15:53:56 +0100
committerquentin@aristote.fr <quentin@aristote.fr>2025-01-29 15:53:56 +0100
commitb8979ecffefdf18ce8a3cc3459adda8f6dabbd33 (patch)
tree015e20b5732fa03733d0c78a98291af564557871 /modules
parent802d7b1608634e0bda5a1bccf43e93a1a1fb8d04 (diff)
nixos: upgrade: restart if no network
Diffstat (limited to 'modules')
-rw-r--r--modules/nixos/personal/nix.nix14
1 files changed, 11 insertions, 3 deletions
diff --git a/modules/nixos/personal/nix.nix b/modules/nixos/personal/nix.nix
index e3f7395..94848d9 100644
--- a/modules/nixos/personal/nix.nix
+++ b/modules/nixos/personal/nix.nix
@@ -57,7 +57,7 @@ in {
(lib.mkIf cfg.autoUpgrade.enable {
# upgrading
flake-update = lib.mkIf (cfg.flake != null && cfg.autoUpgrade.autoUpdateInputs != []) {
- preStart = "${pkgs.host}/bin/host 9.9.9.9"; # Check network connectivity
+ preStart = "${pkgs.host}/bin/host 9.9.9.9 || exit 100"; # Check network connectivity
unitConfig = {
Description = "Update flake inputs";
StartLimitIntervalSec = 300;
@@ -65,7 +65,7 @@ in {
};
serviceConfig = {
ExecStart = "${config.nix.package}/bin/nix flake update --commit-lock-file --flake ${cfg.flake} " + lib.concatStringsSep " " cfg.autoUpgrade.autoUpdateInputs;
- Restart = "on-failure";
+ RestartForceExitCode = "100";
RestartSec = "30";
Type = "oneshot"; # Ensure that it finishes before starting nixos-upgrade
};
@@ -74,7 +74,15 @@ in {
personal.monitor = true;
};
nixos-upgrade = {
- preStart = "${pkgs.host}/bin/host 9.9.9.9"; # Check network connectivity
+ preStart = "${pkgs.host}/bin/host 9.9.9.9 || exit 100"; # Check network connectivity
+ unitConfig = {
+ StartLimitIntervalSec = 300;
+ StartLimitBurst = 5;
+ };
+ serviceConfig = {
+ RestartForceExitCode = "100";
+ RestartSec = "30";
+ };
after = ["flake-update.service"];
wants = ["flake-update.service"];
personal.monitor = true;