This commit is contained in:
Robin Appelman 2024-01-27 17:56:08 +01:00
commit 6081cf31ec

View file

@ -54,6 +54,12 @@ in {
description = "File containing the device password"; description = "File containing the device password";
}; };
interval = mkOption {
type = types.str;
default = "daily";
description = "Interval to run the backup";
};
package = mkOption { package = mkOption {
type = types.package; type = types.package;
defaultText = literalExpression "pkgs.tasproxy"; defaultText = literalExpression "pkgs.tasproxy";
@ -63,7 +69,7 @@ in {
config = mkIf cfg.enable { config = mkIf cfg.enable {
systemd.services."tasmota-backup" = { systemd.services."tasmota-backup" = {
wantedBy = ["multi-user.target"]; description = "Backup tasmota configurations";
serviceConfig = { serviceConfig = {
ExecStart = "${cfg.package}/bin/tasmota-backup ${configFile}"; ExecStart = "${cfg.package}/bin/tasmota-backup ${configFile}";
@ -96,5 +102,16 @@ in {
RestrictSUIDSGID = true; RestrictSUIDSGID = true;
}; };
}; };
systemd.timers."tasmota-backup" = {
inherit (config.systemd.services."tasmota-backup") description;
enable = true;
wantedBy = ["multi-user.target"];
timerConfig = {
OnCalendar = cfg.interval;
RandomizedDelaySec = "15m";
};
};
}; };
} }