modules/nixfiles/nixfiles-system-upgrade.nix,modules/clerie-system-upgrade: rename module
This commit is contained in:
53
modules/clerie-system-upgrade/default.nix
Normal file
53
modules/clerie-system-upgrade/default.nix
Normal file
@@ -0,0 +1,53 @@
|
||||
{ pkgs, lib, config, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
let
|
||||
cfg = config.clerie.system-auto-upgrade;
|
||||
in
|
||||
|
||||
{
|
||||
options = {
|
||||
clerie.system-auto-upgrade = {
|
||||
enable = mkEnableOption "clerie system upgrade";
|
||||
allowReboot = mkOption {
|
||||
type = types.bool;
|
||||
default = false;
|
||||
description = "Monitor NixOS";
|
||||
};
|
||||
autoUpgrade = mkOption {
|
||||
type = types.bool;
|
||||
default = false;
|
||||
description = "Automatically check and install upgrades";
|
||||
};
|
||||
startAt = mkOption {
|
||||
type = with types; nullOr string;
|
||||
default = null;
|
||||
description = "Systemd time string for starting the unit";
|
||||
};
|
||||
};
|
||||
};
|
||||
config = mkIf cfg.enable {
|
||||
systemd.services.clerie-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.clerie-system-auto-upgrade = mkIf cfg.autoUpgrade {
|
||||
wantedBy = [ "timers.target" ];
|
||||
timerConfig = {
|
||||
OnCalendar = if cfg.startAt == null then "*-*-* 05:37:00" else cfg.startAt;
|
||||
RandomizedDelaySec = if cfg.startAt == null then "2h" else "10m";
|
||||
};
|
||||
after = [ "network-online.target" ];
|
||||
};
|
||||
environment.systemPackages = with pkgs; [
|
||||
nixfiles-system-upgrade
|
||||
];
|
||||
};
|
||||
}
|
Reference in New Issue
Block a user