1
0
Fork 0
mirror of https://github.com/nix-community/home-manager.git synced 2025-11-08 19:46:05 +01:00

newsboat: add timer unit for automatically fetching articles

This commit is contained in:
h7x4 2025-10-11 23:04:21 +09:00 committed by Austin Horstman
parent 6ea30b26cd
commit a264fbea00

View file

@ -142,6 +142,21 @@ in
Extra configuration values that will be appended to the end.
'';
};
auto-fetch-articles = {
enable = lib.mkEnableOption "automatic article fetcher timer";
onCalendar = lib.mkOption {
type = lib.types.str;
default = "daily";
example = "weekly";
description = ''
How often to fetch new articles.
See {manpage}`systemd.time(7)` for more information about the format.
'';
};
};
};
};
@ -154,6 +169,12 @@ in
want to manage urls imperatively.
'';
}
{
assertion = cfg.auto-fetch-articles.enable -> cfg.package != null;
message = ''
Cannot fetch articles if package is unset.
'';
}
];
home.packages = lib.mkIf (cfg.package != null) [ cfg.package ];
@ -168,5 +189,39 @@ in
"newsboat/urls" = mkIf (cfg.urls != [ ]) { text = urlsFileContents; };
"newsboat/config".text = configFileContents;
};
systemd.user.services.newsboat-fetch-articles = lib.mkIf cfg.auto-fetch-articles.enable {
Unit = {
Description = "Automatic Newsboat Article Fetcher";
Documentation = [ "man:newsboat(1)" ];
};
Service = {
Type = "oneshot";
Slice = "background.slice";
CPUSchedulingPolicy = "idle";
IOSchedulingClass = "idle";
RuntimeDirectory = "newsboat";
ExecStart = "${lib.getExe pkgs.flock} %t/newsboat.lock ${lib.getExe cfg.package} --execute=reload";
};
};
systemd.user.timers.newsboat-fetch-articles = lib.mkIf cfg.auto-fetch-articles.enable {
Unit = {
Description = "Automatic Newsboat Article Fetcher";
Documentation = [ "man:newsboat(1)" ];
After = [ "network.target" ];
};
Timer = {
Unit = "newsboat-fetch-articles.service";
OnCalendar = cfg.auto-fetch-articles.onCalendar;
Persistent = true;
};
Install = {
WantedBy = [ "timers.target" ];
};
};
};
}