Create a systemd service and timer to run

...imapfilter
This commit is contained in:
Oliver Davies 2025-05-06 20:17:29 +01:00
parent f3713050cb
commit 75acfc3dcf
3 changed files with 50 additions and 2 deletions
home/opdavies
hosts/t490/services

View file

@ -1,5 +1,9 @@
{
imports = [ ../common ];
imports = [
../common
./nixedo/modules/email-filters.nix
];
cli = {
fzf.enable = true;

View file

@ -0,0 +1,45 @@
{
config,
lib,
pkgs,
...
}:
let
cfg = config.nixedo.${name};
name = "email-filters";
in
{
options.nixedo.${name} = {
configFile = lib.mkOption {
default = "${config.home.homeDirectory}/Code/${name}/config.lua";
internal = true;
};
};
config = {
systemd.user = {
services.${name} = {
Install.WantedBy = [ "default.target" ];
Service = {
ExecStart = "${lib.getExe pkgs.imapfilter} -c ${cfg.configFile}";
Type = "oneshot";
};
Unit.Description = name;
};
timers.${name} = {
Install.WantedBy = [ "timers.target" ];
Timer = {
OnCalendar = "*-*-* 06..23:00/5";
Unit = "${name}.service";
};
Unit.Description = "Automatically runs email filters with imapfilter.";
};
};
};
}

View file

@ -5,7 +5,6 @@
enable = true;
systemCronJobs = [
"*/15 * * * * opdavies ${pkgs.imapfilter}/bin/imapfilter -c ~/Code/email-filters/config.lua"
"0 8,20 * * * opdavies ${pkgs.isync}/bin/mbsync -a"
];
};