From f1b915373750f7bdc09cbdaa011d0f49efea6cc8 Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Sat, 12 Mar 2022 20:55:33 +0100 Subject: rebuild-machines: period --- system-profiles/networkmanager.nix | 2 ++ system-profiles/rebuild-machines/default.nix | 29 ++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+) (limited to 'system-profiles') diff --git a/system-profiles/networkmanager.nix b/system-profiles/networkmanager.nix index d1eb9cd1..878a12c4 100644 --- a/system-profiles/networkmanager.nix +++ b/system-profiles/networkmanager.nix @@ -22,5 +22,7 @@ with lib; systemd.services."systemd-networkd-wait-online".enable = false; services.resolved.enable = false; + + environment.noXlibs = false; }; } diff --git a/system-profiles/rebuild-machines/default.nix b/system-profiles/rebuild-machines/default.nix index e2a15aae..68788023 100644 --- a/system-profiles/rebuild-machines/default.nix +++ b/system-profiles/rebuild-machines/default.nix @@ -90,6 +90,13 @@ in { format = "binary"; }; }; + + period = mkOption { + type = types.nullOr types.str; + description = "Call rebuild-${hostName} boot periodically"; + default = null; + example = "hourly"; + }; }; }; @@ -107,5 +114,27 @@ in { }; environment.systemPackages = [ rebuildScript ]; + + systemd.services."rebuild-${hostName}" = lib.mkIf (cfg.period != null) { + description = "Upgrade System on Next Boot"; + requisite = [ "network.target" ]; + after = [ "network.target" ]; + + restartIfChanged = false; + unitConfig.X-StopOnRemoval = false; + + serviceConfig = { + Type = "oneshot"; + ExecStart = "${rebuildScript}/bin/${cfg.scriptName} boot"; + }; + }; + + systemd.timers."rebuild-${hostName}" = lib.mkIf (cfg.period != null) { + wantedBy = [ "timers.target" ]; + timerConfig = { + OnCalendar = cfg.period; + Persistent = true; + }; + }; }; } -- cgit v1.2.3