summaryrefslogtreecommitdiff
path: root/system-profiles/rebuild-machines/default.nix
diff options
context:
space:
mode:
Diffstat (limited to 'system-profiles/rebuild-machines/default.nix')
-rw-r--r--system-profiles/rebuild-machines/default.nix29
1 files changed, 29 insertions, 0 deletions
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 {
90 format = "binary"; 90 format = "binary";
91 }; 91 };
92 }; 92 };
93
94 period = mkOption {
95 type = types.nullOr types.str;
96 description = "Call <code>rebuild-${hostName} boot</code> periodically";
97 default = null;
98 example = "hourly";
99 };
93 }; 100 };
94 }; 101 };
95 102
@@ -107,5 +114,27 @@ in {
107 }; 114 };
108 115
109 environment.systemPackages = [ rebuildScript ]; 116 environment.systemPackages = [ rebuildScript ];
117
118 systemd.services."rebuild-${hostName}" = lib.mkIf (cfg.period != null) {
119 description = "Upgrade System on Next Boot";
120 requisite = [ "network.target" ];
121 after = [ "network.target" ];
122
123 restartIfChanged = false;
124 unitConfig.X-StopOnRemoval = false;
125
126 serviceConfig = {
127 Type = "oneshot";
128 ExecStart = "${rebuildScript}/bin/${cfg.scriptName} boot";
129 };
130 };
131
132 systemd.timers."rebuild-${hostName}" = lib.mkIf (cfg.period != null) {
133 wantedBy = [ "timers.target" ];
134 timerConfig = {
135 OnCalendar = cfg.period;
136 Persistent = true;
137 };
138 };
110 }; 139 };
111} 140}