-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodule.nix
54 lines (53 loc) · 1.35 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
{
lib,
pkgs,
config,
...
}:
let
cfg = config.services.brockman-api;
in
{
options.services.brockman-api = {
enable = lib.mkEnableOption "brockman api service";
package = lib.mkOption {
type = lib.types.package;
default = pkgs.python3.pkgs.callPackage ./default.nix { };
};
port = lib.mkOption {
type = lib.types.int;
default = 7331;
description = "Port to listen on";
};
irc-server = lib.mkOption {
type = lib.types.string;
default = "brockman.news";
description = "IRC server to connect to";
};
control-channel = lib.mkOption {
type = lib.types.string;
default = "#all";
description = "IRC channel to listen on";
};
openFirewall = lib.mkEnableOption "open port in firewall";
};
config = lib.mkIf cfg.enable {
networking.firewall.allowedTCPPorts = lib.mkIf cfg.openFirewall [ cfg.port ];
systemd.services.brockman-api = {
description = "brockman api service";
wantedBy = [ "multi-user.target" ];
after = [
"network.target"
];
serviceConfig = {
ExecStart = ''
${cfg.package}/bin/brockman-api \
--port ${toString cfg.port} \
--irc-server ${cfg.irc-server} \
--control-channel ${cfg.control-channel}
'';
StateDirectory = "goto";
};
};
};
}