-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodule.nix
57 lines (53 loc) · 1.4 KB
/
module.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
self: { config, lib, pkgs, ... }: let
cfg = config.services.tsoping;
in {
imports = [];
options = {
services.tsoping = let inherit (lib) mkOption types; in {
enable = mkOption {
type = types.bool;
default = false;
description = ''
Enable Tsoping, a service to send a link to a Telegram chat when Tsoding uploads a new video.
'';
};
chat-id-file = mkOption {
type = types.path;
};
telegram-token-file = mkOption {
type = types.path;
};
};
};
config = lib.mkIf cfg.enable {
users.users.tsoping = {
description = "Tsoping service user";
isSystemUser = true;
group = "tsoping";
createHome = true;
home = "/home/tsoping";
};
users.groups.tsoping = {};
systemd.services.tsoping = {
after = [ "network-online.target" ];
wants = [ "network-online.target" ];
wantedBy = [ "multi-user.target" ];
script = ''
cd /home/tsoping
\
TSOPING_CHAT_ID_FILE="${cfg.chat-id-file}" \
TSOPING_TELEGRAM_TOKEN_FILE="${cfg.telegram-token-file}" \
exec \
${self.packages.${pkgs.system}.tsoping}/bin/tsoping run \
;
'';
serviceConfig = {
Type = "oneshot";
User = "tsoping";
Group = "tsoping";
};
startAt = "hourly";
restartIfChanged = false;
};
};
}