1
0
Fork 0
nixfiles/modules/nixfiles/nixfiles-system-upgrade.nix

41 lines
1.2 KiB
Nix

{ pkgs, lib, config, ... }:
with lib;
let
cfg = config.clerie.nixfiles.system-auto-upgrade;
in
{
options = {
clerie.nixfiles.system-auto-upgrade = {
enable = mkEnableOption "clerie nixfiles tools";
allowReboot = mkOption {
type = types.bool;
default = false;
description = "Monitor NixOS";
};
};
};
config = mkIf cfg.enable {
systemd.services.nixfiles-system-auto-upgrade = {
# Make sure this unit does not stop themself while upgrading
restartIfChanged = false;
unitConfig.X-StopOnRemoval = false;
serviceConfig = {
Type = "oneshot";
ExecStart = pkgs.nixfiles-system-upgrade + "/bin/nixfiles-system-upgrade --no-confirm${optionalString cfg.allowReboot " --allow-reboot"}${optionalString (config.clerie.monitoring.enable) " --node-exporter-metrics-path /var/lib/prometheus-node-exporter/textfiles/nixfiles-system-upgrade.prom"}";
};
};
systemd.timers.nixfiles-system-auto-upgrade = {
wantedBy = [ "timers.target" ];
timerConfig = {
OnCalendar = "*-*-* 05:37:00";
RandomizedDelaySec = "2h";
};
after = [ "network-online.target" ];
};
};
}