summaryrefslogtreecommitdiff
path: root/modules/nixos/personal
diff options
context:
space:
mode:
authoraristote <quentin.aristote@irif.fr>2025-11-21 09:49:24 +0100
committeraristote <quentin.aristote@irif.fr>2025-11-21 10:15:47 +0100
commitc032f4c09c83feb933d520ccce80e70a1516ca35 (patch)
tree6c4a861632f3979c9c287b5983a36776317a5932 /modules/nixos/personal
parent4d3eeda464341243be3fc6c3fbb4a5f1d0ead906 (diff)
home: check network before daily services
Diffstat (limited to 'modules/nixos/personal')
-rw-r--r--modules/nixos/personal/system.nix26
1 files changed, 8 insertions, 18 deletions
diff --git a/modules/nixos/personal/system.nix b/modules/nixos/personal/system.nix
index 3337b96..559b3fc 100644
--- a/modules/nixos/personal/system.nix
+++ b/modules/nixos/personal/system.nix
@@ -68,29 +68,16 @@ in
remoteBuilder = with cfgRemote.builder; "${hostName}.${domain}";
- checkNetwork = {
- path = [ pkgs.unixtools.ping ];
- # Check network connectivity
- preStart = "(${
- lib.concatMapStringsSep " && " (host: "ping -c 1 ${host}") cfg.autoUpgrade.checkHosts
- }) || kill -s SIGUSR1 $$";
- unitConfig = {
- StartLimitIntervalSec = 300;
- StartLimitBurst = 5;
- };
- serviceConfig = lib.mkIf (!config.personal.monitoring.enable) {
- Restart = "on-abort";
- RestartSec = 30;
- RestartMode = "direct"; # dependent units will not fail
- };
- };
in
lib.mkMerge [
(lib.mkIf hasFlake {
system.autoUpgrade.flake = cfg.flake;
systemd.services.flake-update = lib.mkIf hasFlakeInputs (
lib.mkMerge [
- checkNetwork
+ (pkgs.lib.personal.services.checkNetwork {
+ hosts = cfg.autoUpgrade.checkHosts;
+ restart = !config.personal.monitoring.enable;
+ })
{
description = "Update flake inputs";
serviceConfig.Type = "oneshot";
@@ -146,7 +133,10 @@ in
flags = lib.optional (!hasFlake) "--upgrade-all";
};
systemd.services.nixos-upgrade = lib.mkMerge [
- checkNetwork
+ (pkgs.lib.personal.services.checkNetwork {
+ hosts = cfg.autoUpgrade.checkHosts;
+ restart = !config.personal.monitoring.enable;
+ })
{
path =
lib.optional reboot pkgs.coreutils