blob: 944e5828fe0ae8a30048d322a9908d7190110aee (
plain) (
blame)
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
|
{ config, pkgs, ... }:
with pkgs.lib;
let
cfg = config.services.supybot;
in
{
###### interface
options = {
services.supybot = {
enable = mkOption {
default = false;
description = "Enable Supybot, an IRC bot";
};
stateDir = mkOption {
default = "/var/lib/supybot";
description = "
";
};
configFile = mkOption {
type = types.path;
default = /dev/null;
description = ''
Verbatim contents of the supybot config, this can be
generated by supybot-wizard
'';
};
user = mkOption {
default = "supybot";
description = "User account under which supybot runs.";
};
group = mkOption {
default = "supybot";
description = "Group account under which supybot runs.";
};
};
};
###### implementation
config = mkIf cfg.enable {
environment.systemPackages = [ pkgs.pythonPackages.limnoria ];
users.extraUsers = singleton
{ name = cfg.user;
uid = config.ids.uids.supybot;
group = "supybot";
description = "Supybot IRC bot user";
home = cfg.stateDir;
createHome = true;
};
users.extraGroups.supybot = {};
systemd.services.supybot =
{ description = "Supybot IRC bot";
after = [ "network.target" ];
wantedBy = [ "multi-user.target" ];
path = [ pkgs.pythonPackages.limnoria ];
preStart = ''
mkdir -m 0755 -p ${cfg.stateDir}
chown ${cfg.user}:${cfg.group} ${cfg.stateDir}
cd ${cfg.stateDir}
mkdir -p logs/plugins backup conf data plugins tmp
ln -sf ${cfg.configFile} supybot.cfg
rm -f supybot.cfg.bak
'';
serviceConfig =
{ ExecStart =
"${pkgs.pythonPackages.limnoria}/bin/supybot ${cfg.stateDir}/supybot.cfg";
PIDFile = "/run/supybot.pid";
User = "${cfg.user}";
Group = "${cfg.group}";
UMask = "0007";
Restart = "on-abort";
StartLimitInterval = "5m";
StartLimitBurst = "1";
};
};
};
}
|