mirror of
https://github.com/nix-community/home-manager.git
synced 2025-11-09 03:56:04 +01:00
newsboat: add timer unit for automatically fetching articles
This commit is contained in:
parent
6ea30b26cd
commit
a264fbea00
1 changed files with 55 additions and 0 deletions
|
|
@ -142,6 +142,21 @@ in
|
||||||
Extra configuration values that will be appended to the end.
|
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.
|
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 ];
|
home.packages = lib.mkIf (cfg.package != null) [ cfg.package ];
|
||||||
|
|
@ -168,5 +189,39 @@ in
|
||||||
"newsboat/urls" = mkIf (cfg.urls != [ ]) { text = urlsFileContents; };
|
"newsboat/urls" = mkIf (cfg.urls != [ ]) { text = urlsFileContents; };
|
||||||
"newsboat/config".text = configFileContents;
|
"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" ];
|
||||||
|
};
|
||||||
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue