summaryrefslogtreecommitdiffstats
path: root/nixos/modules/services/networking/inspircd.nix
blob: 0bcc702cba81c2d9864992eeb03b31ef9e9b84c2 (plain)
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
{
  config,
  lib,
  pkgs,
  ...
}:

let
  cfg = config.services.inspircd;

  configFile = pkgs.writeText "inspircd.conf" cfg.config;

in
{
  meta = {
    maintainers = [ lib.maintainers.sternenseemann ];
  };

  options = {
    services.inspircd = {
      enable = lib.mkEnableOption "InspIRCd";

      package = lib.mkOption {
        type = lib.types.package;
        default = pkgs.inspircd;
        defaultText = lib.literalExpression "pkgs.inspircd";
        example = lib.literalExpression "pkgs.inspircdMinimal";
        description = ''
          The InspIRCd package to use. This is mainly useful
          to specify an overridden version of the
          `pkgs.inspircd` dervivation, for
          example if you want to use a more minimal InspIRCd
          distribution with less modules enabled or with
          modules enabled which can't be distributed in binary
          form due to licensing issues.
        '';
      };

      config = lib.mkOption {
        type = lib.types.lines;
        description = ''
          Verbatim {file}`inspircd.conf` file.
          For a list of options, consult the
          [InspIRCd documentation](https://docs.inspircd.org/3/configuration/), the
          [Module documentation](https://docs.inspircd.org/3/modules/)
          and the example configuration files distributed
          with `pkgs.inspircd.doc`
        '';
      };
    };
  };

  config = lib.mkIf cfg.enable {
    systemd.services.inspircd = {
      description = "InspIRCd - the stable, high-performance and modular Internet Relay Chat Daemon";
      unitConfig.Documentation = "https://docs.inspircd.org";
      wantedBy = [ "multi-user.target" ];

      after = [
        "network.target"
        "network-online.target"
      ];
      wants = [ "network-online.target" ];

      serviceConfig = {
        Type = "simple";
        ExecStart = ''
          ${lib.getBin cfg.package}/bin/inspircd --config ${configFile} --nofork --nopid
        '';
        ExecReload = "${pkgs.coreutils}/bin/kill -HUP $MAINPID";
        Restart = "on-failure";
        DynamicUser = true;
      };
    };
  };
}