This repository has been archived by the owner on Nov 9, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathmodule.nix
69 lines (66 loc) · 1.66 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
{ lib, pkgs, config, ... }:
with lib;
{
options.services.tigger = {
enable = mkOption {
type = types.bool;
default = true;
description = "Enable the bot";
};
user = mkOption {
type = types.str;
};
group = mkOption {
type = types.str;
};
jid = mkOption {
type = types.str;
description = "Jabber-ID";
};
password = mkOption {
type = types.nullOr types.str;
default = null;
description = "Jabber password";
};
passwordFile = mkOption {
type = types.str;
default = null;
description = "Jabber password in a file";
};
mucs = mkOption {
type = types.listOf types.str;
description = "MUC Jabber-IDs";
};
};
config =
let
cfg = config.services.tigger;
tigger = pkgs.callPackage ./default.nix {};
in mkIf cfg.enable {
systemd.services.tigger = {
description = "MUC bot";
wantedBy = [ "multi-user.target" ];
after = [ "network.target" ];
script = ''
${lib.getExe tigger} ${with cfg; concatStringsSep " " ([jid]
++ lib.optional (password != null) password
++ lib.optional (passwordFile != null) "$(cat ${passwordFile})"
++ mucs)}
'';
serviceConfig = {
Type = "simple";
Restart = "always";
RestartSec = "10min";
User = cfg.user;
Group = cfg.group;
NoNewPrivileges = true;
LimitNPROC = 32;
LimitNOFILE = 1024;
CPUWeight = 5;
MemoryMax = "512M";
ProtectSystem = "full";
ProtectHome = "tmpfs";
};
};
};
}