all repos — nixfiles @ 3829da7df19192a1381a057f140bd4166b86a212

System and user configuration, managed by nix and home-manager

system/settings/configuration/auto-upgrade.nix (view raw)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
{
  config,
  lib,
  ...
}:
let
  nixfiles = "${config.users.users.alin.home}/projects/alin.ovh/nixfiles";
in
{
  systemd.services.update-nixfiles = {
    startAt = config.system.autoUpgrade.dates;
    wantedBy = [ "nixos-upgrade.service" ];
    path = [ config.programs.git.package ];
    serviceConfig = {
      Type = "oneshot";
      User = "alin";
      WorkingDirectory = "-${nixfiles}";
    };
    script = ''
      if [ ! -d "${nixfiles}" ]
      then
        mkdir -p "${nixfiles}"
        cd "${nixfiles}"
        git clone git+ssh://gitolite@git.alin.ovh/nixfiles .
      else
        git checkout -- flake.lock
        git pull --recurse-submodules=yes
      fi
    '';
  };

  system.autoUpgrade = {
    enable = true;
    allowReboot = true;

    dates = "02:10";
    randomizedDelaySec = "59 min";
    rebootWindow = lib.mkDefault {
      lower = "01:00";
      upper = "06:00";
    };

    flake = "${nixfiles}?submodules=1";
    upgrade = false;
  };
}