make all servers auto-upgrade
1 file changed, 40 insertions(+), 0 deletions(-)
changed files
A system/settings/configuration/auto-upgrade.nix
@@ -0,0 +1,40 @@ +{ + config, + pkgs, + ... +}: +{ + systemd.services.update-nixfiles = { + startAt = config.system.autoUpgrade.dates; + wantedBy = [ "nixos-upgrade.service" ]; + path = with pkgs; [ + openssh + nix + config.programs.git.package + ]; + serviceConfig = { + Type = "oneshot"; + User = "alin"; + WorkingDirectory = "${config.users.users.alin.home}/projects/alin.ovh/nixfiles"; + }; + script = '' + git checkout -- flake.lock + git pull --recurse-submodules=yes + nix flake update + ''; + }; + + system.autoUpgrade = { + enable = true; + allowReboot = true; + + dates = "02:10"; + randomizedDelaySec = "59 min"; + rebootWindow = { + lower = "01:00"; + upper = "06:00"; + }; + + flake = "${config.systemd.services.update-nixfiles.serviceConfig.WorkingDirectory}?submodules=1"; + }; +}