1
0

modules/nixfiles: Deploy system upgrade unit everywhere so updates can get startet remotely

This commit is contained in:
clerie 2023-12-15 20:20:53 +01:00
parent d05f74ece9
commit 98de6489f3
7 changed files with 15 additions and 6 deletions

View File

@ -4,6 +4,8 @@
clerie.nixfiles.enable = true; clerie.nixfiles.enable = true;
clerie.nixfiles.system-auto-upgrade.enable = true;
nix.settings = { nix.settings = {
trusted-users = [ "@wheel" "@guests" ]; trusted-users = [ "@wheel" "@guests" ];
auto-optimise-store = true; auto-optimise-store = true;

View File

@ -10,7 +10,6 @@
colmena colmena
vim vim
agenix agenix
nixfiles-system-upgrade
]; ];
programs.mtr.enable = true; programs.mtr.enable = true;

View File

@ -330,8 +330,8 @@
''; '';
clerie.nixfiles.system-auto-upgrade = { clerie.nixfiles.system-auto-upgrade = {
enable = true;
allowReboot = true; allowReboot = true;
autoUpgrade = true;
}; };
clerie.monitoring = { clerie.monitoring = {

View File

@ -184,8 +184,8 @@
''; '';
clerie.nixfiles.system-auto-upgrade = { clerie.nixfiles.system-auto-upgrade = {
enable = true;
allowReboot = true; allowReboot = true;
autoUpgrade = true;
startAt = "*-*-* 06:22:00"; startAt = "*-*-* 06:22:00";
}; };

View File

@ -184,8 +184,8 @@
''; '';
clerie.nixfiles.system-auto-upgrade = { clerie.nixfiles.system-auto-upgrade = {
enable = true;
allowReboot = true; allowReboot = true;
autoUpgrade = true;
startAt = "*-*-* 07:22:00"; startAt = "*-*-* 07:22:00";
}; };

View File

@ -40,8 +40,8 @@
networking.firewall.allowedUDPPorts = []; networking.firewall.allowedUDPPorts = [];
clerie.nixfiles.system-auto-upgrade = { clerie.nixfiles.system-auto-upgrade = {
enable = true;
allowReboot = true; allowReboot = true;
autoUpgrade = true;
}; };
clerie.monitoring = { clerie.monitoring = {

View File

@ -15,6 +15,11 @@ in
default = false; default = false;
description = "Monitor NixOS"; description = "Monitor NixOS";
}; };
autoUpgrade = mkOption {
type = types.bool;
default = false;
description = "Automatically check and install upgrades";
};
startAt = mkOption { startAt = mkOption {
type = with types; nullOr string; type = with types; nullOr string;
default = null; default = null;
@ -33,7 +38,7 @@ in
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"}"; 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 = { systemd.timers.nixfiles-system-auto-upgrade = mkIf cfg.autoUpgrade {
wantedBy = [ "timers.target" ]; wantedBy = [ "timers.target" ];
timerConfig = { timerConfig = {
OnCalendar = if cfg.startAt == null then "*-*-* 05:37:00" else cfg.startAt; OnCalendar = if cfg.startAt == null then "*-*-* 05:37:00" else cfg.startAt;
@ -41,5 +46,8 @@ in
}; };
after = [ "network-online.target" ]; after = [ "network-online.target" ];
}; };
environment.systemPackages = with pkgs; [
nixfiles-system-upgrade
];
}; };
} }