Implement built-in cron worker

This commit is contained in:
2025-06-04 16:49:00 +02:00
parent 9bc036113f
commit ec3c1e541c
8 changed files with 55 additions and 58 deletions

View File

@@ -28,13 +28,6 @@ in
default = "root";
};
scanTimer = mkOption {
type = types.str;
description = "The systemd's timer interval when the app will be performing the scan for new tasks";
example = "*-*-* *:00";
default = "*-*-* *:10";
};
config = mkOption {
type = types.attrs;
description = "The obsidian-tasks-reminder config which will be eventually converted to yaml";
@@ -56,46 +49,17 @@ in
config = mkIf cfg.enable {
environment.systemPackages = [app];
systemd.timers.obsidian-tasks-reminder-scanner = {
description = "Scan for new Obsidian tasks";
wantedBy = ["timers.target"];
timerConfig = {
OnCalendar = cfg.scanTimer;
Unit = "obsidian-tasks-reminder-scanner.service";
};
};
systemd.timers.obsidian-tasks-reminder = {
description = "Notify about Obsidian tasks";
wantedBy = ["timers.target"];
timerConfig = {
OnCalendar = "*-*-* *:*:00";
Unit = "obsidian-tasks-reminder.service";
};
};
systemd.services.obsidian-tasks-reminder-scanner = {
description = "Scan for new Obsidian tasks";
serviceConfig = {
Type = "oneshot";
User = cfg.user;
};
script = "${app}/bin/obsidian-tasks-reminder -s";
};
systemd.services.obsidian-tasks-reminder = {
description = "Notify about Obsidian tasks";
enable = true;
description = "Obsidian Tasks Notifier";
wantedBy = ["network-online.target"];
after = ["network-online.target"];
serviceConfig = {
Type = "oneshot";
ExecStart = "${app}/bin/obsidian-tasks-reminder";
User = cfg.user;
};
script = "${app}/bin/obsidian-tasks-reminder -n";
};
};
}