-
Notifications
You must be signed in to change notification settings - Fork 4
/
rss_to_mail.nix
57 lines (49 loc) · 1.41 KB
/
rss_to_mail.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
{ config, pkgs, lib, ... }:
# Run rss_to_mail periodically for a list of users.
#
# Using instiancied units rather than users units to keep things declarative.
# Rss_to_mail will be run as the target users and data will be stored in home
# directories.
#
# Usage:
# services.rss_to_mail = {
# enable = true;
# users = [ "foo" "bar" ];
# };
let
rss_to_mail = pkgs.rss_to_mail;
conf = config.services.rss_to_mail;
in
{
options.services.rss_to_mail = with lib; {
enable = mkEnableOption "rss_to_mail";
users = mkOption {
type = types.nonEmptyListOf types.str;
default = [];
description = "Users for which to enable Rss_to_mail.";
};
};
config = lib.mkIf conf.enable {
# Instance name is user
systemd.services."rss_to_mail@" = {
description = "Rss_to_mail for user %i.";
serviceConfig = {
Type = "oneshot";
WorkingDirectory = "~";
User = "%i";
Environment="CA_BUNDLE=${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt";
ExecStart = "${rss_to_mail}/bin/rss_to_mail";
};
};
systemd.timers."rss_to_mail@" = {
description = "Runs rss_to_mail every 10 minutes";
timerConfig = {
OnBootSec = "10m";
OnUnitInactiveSec = "10m";
Unit = "rss_to_mail@%i.service";
};
};
# Instanciate timers
systemd.targets.timers.wants = map (u: "rss_to_mail@${u}.timer") conf.users;
};
}