-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodule.nix
81 lines (78 loc) · 2.29 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# vim: tabstop=2 shiftwidth=2 expandtab:
{ lib, pkgs, config, ... }:
with lib;
{
options.services.fdroid-news = {
enable = mkOption {
type = types.bool;
default = true;
description = "Enable fdroid-news bot";
};
username = mkOption {
type = types.str;
description = "JID of the user the bot should use";
};
host = mkOption {
type = types.str;
description = "Host the bot connect to";
};
password = mkOption {
type = types.str;
description = "XMPP Password";
default = "";
};
passwordFile = mkOption {
type = types.str;
description = "Optional password file";
};
muc = mkOption {
type = types.str;
description = "MUC the bot should join";
};
nick = mkOption {
type = types.str;
description = "Nick the bot should use";
};
repos = mkOption {
type = types.listOf types.str;
description = "List of repos the bot should monitor";
};
user = mkOption {
type = types.str;
};
group = mkOption {
type = types.str;
};
debugMode = mkOption {
type = types.bool;
};
};
config =
let
cfg = config.services.fdroid-news;
fdroid-news = pkgs.fdroid-news;
in mkIf cfg.enable {
environment.etc."fdroid-news/config.yml".source = (pkgs.formats.yaml {}).generate "config.yml" {xmpp = removeAttrs cfg ["enable" "repos" "passowrdFile" "debugMode"]; repos = cfg.repos;};
systemd.services.fdroid-news = {
description = "fdroid-news bot";
wantedBy = [ "multi-user.target" ];
after = [ "network.target" ];
serviceConfig = {
Type = "simple";
ExecStart = "${fdroid-news}/bin/fdroid-news -c /etc/fdroid-news/config.yml"
+ optionalString (cfg.passwordFile != null) " -p ${cfg.passwordFile}"
+ optionalString (cfg.debugMode) " -v";
StateDirectory = "fdroid-news";
ConfigurationDirectory = "fdroid-news";
WorkingDirectory = "/var/lib/fdroid-news";
Restart = "always";
RestartSec = "5min";
User = cfg.user;
Group = cfg.group;
NoNewPriviliges = true;
ProtectHome = "tmpfs";
ProtectSystem = "strict";
};
};
};
}