[microvm] automatic update from master every 20mins

This commit is contained in:
2024-11-23 12:30:29 +01:00
parent c54d27bceb
commit e5e3433df0

View File

@@ -85,5 +85,36 @@ in
}; };
in
builtins.listToAttrs (map mapperFunc cfg.deployHosts);
systemd.services = builtins.foldl' (services: name: services // {
"microvm-update@${name}" = {
description = "Update MicroVMs automatically";
after = [ "network-online.target" ];
wants = [ "network-online.target" ];
unitConfig.ConditionPathExists = "/var/lib/microvms/${name}";
serviceConfig = {
LimitNOFILE = "1048576";
Type = "oneshot";
};
path = with pkgs; [ nix git ];
environment.HOME = config.users.users.root.home;
scriptArgs = "%i";
script = ''
/run/current-system/sw/bin/microvm -Ru ${name}
'';
};
}) {} (cfg.deployHosts);
systemd.timers = builtins.foldl' (timers: name: timers // {
"microvm-update-${name}" = {
wantedBy = [ "timers.target" ];
timerConfig = {
Unit = "microvm-update@${name}.service";
# three times per hour
OnCalendar = "*:0,20,40:00";
Persistent = true;
};
};
}) {} (cfg.deployHosts);
};
}