1{ config, lib, pkgs, ... }:
2
3let
4 cfg = config.services.inspircd;
5
6 configFile = pkgs.writeText "inspircd.conf" cfg.config;
7
8in {
9 meta = {
10 maintainers = [ lib.maintainers.sternenseemann ];
11 };
12
13 options = {
14 services.inspircd = {
15 enable = lib.mkEnableOption "InspIRCd";
16
17 package = lib.mkOption {
18 type = lib.types.package;
19 default = pkgs.inspircd;
20 defaultText = lib.literalExample "pkgs.inspircd";
21 example = lib.literalExample "pkgs.inspircdMinimal";
22 description = ''
23 The InspIRCd package to use. This is mainly useful
24 to specify an overridden version of the
25 <literal>pkgs.inspircd</literal> dervivation, for
26 example if you want to use a more minimal InspIRCd
27 distribution with less modules enabled or with
28 modules enabled which can't be distributed in binary
29 form due to licensing issues.
30 '';
31 };
32
33 config = lib.mkOption {
34 type = lib.types.lines;
35 description = ''
36 Verbatim <literal>inspircd.conf</literal> file.
37 For a list of options, consult the
38 <link xlink:href="https://docs.inspircd.org/3/configuration/">InspIRCd documentation</link>, the
39 <link xlink:href="https://docs.inspircd.org/3/modules/">Module documentation</link>
40 and the example configuration files distributed
41 with <literal>pkgs.inspircd.doc</literal>
42 '';
43 };
44 };
45 };
46
47 config = lib.mkIf cfg.enable {
48 systemd.services.inspircd = {
49 description = "InspIRCd - the stable, high-performance and modular Internet Relay Chat Daemon";
50 wantedBy = [ "multi-user.target" ];
51 requires = [ "network.target" ];
52
53 serviceConfig = {
54 Type = "simple";
55 ExecStart = ''
56 ${lib.getBin cfg.package}/bin/inspircd start --config ${configFile} --nofork --nopid
57 '';
58 DynamicUser = true;
59 };
60 };
61 };
62}