2014-04-14 14:26:48 +00:00
|
|
|
{ config, lib, pkgs, ... }:
|
2009-03-06 12:26:55 +00:00
|
|
|
|
2014-04-14 14:26:48 +00:00
|
|
|
with lib;
|
2009-03-06 12:26:55 +00:00
|
|
|
|
|
|
|
let
|
2009-10-12 16:36:19 +00:00
|
|
|
|
2009-03-06 12:26:55 +00:00
|
|
|
cfg = config.services.ircdHybrid;
|
2011-09-14 18:20:50 +00:00
|
|
|
|
2011-04-28 08:23:09 +00:00
|
|
|
ircdService = pkgs.stdenv.mkDerivation rec {
|
2011-04-27 16:27:05 +00:00
|
|
|
name = "ircd-hybrid-service";
|
|
|
|
scripts = [ "=>/bin" ./control.in ];
|
|
|
|
substFiles = [ "=>/conf" ./ircd.conf ];
|
|
|
|
inherit (pkgs) ircdHybrid coreutils su iproute gnugrep procps;
|
|
|
|
|
2012-03-04 12:58:18 +00:00
|
|
|
ipv6Enabled = if config.networking.enableIPv6 then "true" else "false";
|
2011-04-27 16:27:05 +00:00
|
|
|
|
|
|
|
inherit (cfg) serverName sid description adminEmail
|
|
|
|
extraPort;
|
|
|
|
|
2011-09-14 18:20:50 +00:00
|
|
|
cryptoSettings =
|
2011-04-27 16:27:05 +00:00
|
|
|
(optionalString (cfg.rsaKey != null) "rsa_private_key_file = \"${cfg.rsaKey}\";\n") +
|
|
|
|
(optionalString (cfg.certificate != null) "ssl_certificate_file = \"${cfg.certificate}\";\n");
|
|
|
|
|
|
|
|
extraListen = map (ip: "host = \""+ip+"\";\nport = 6665 .. 6669, "+extraPort+"; ") cfg.extraIPs;
|
|
|
|
|
|
|
|
builder = ./builder.sh;
|
2009-03-06 12:26:55 +00:00
|
|
|
};
|
|
|
|
|
2007-08-08 20:42:25 +00:00
|
|
|
in
|
2009-03-06 12:26:55 +00:00
|
|
|
|
2009-10-12 16:36:19 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
###### interface
|
|
|
|
|
|
|
|
options = {
|
2011-09-14 18:20:50 +00:00
|
|
|
|
2009-10-12 16:36:19 +00:00
|
|
|
services.ircdHybrid = {
|
|
|
|
|
|
|
|
enable = mkOption {
|
|
|
|
default = false;
|
|
|
|
description = "
|
|
|
|
Enable IRCD.
|
|
|
|
";
|
|
|
|
};
|
|
|
|
|
|
|
|
serverName = mkOption {
|
|
|
|
default = "hades.arpa";
|
|
|
|
description = "
|
|
|
|
IRCD server name.
|
|
|
|
";
|
|
|
|
};
|
|
|
|
|
|
|
|
sid = mkOption {
|
|
|
|
default = "0NL";
|
|
|
|
description = "
|
|
|
|
IRCD server unique ID in a net of servers.
|
|
|
|
";
|
|
|
|
};
|
|
|
|
|
|
|
|
description = mkOption {
|
|
|
|
default = "Hybrid-7 IRC server.";
|
|
|
|
description = "
|
|
|
|
IRCD server description.
|
|
|
|
";
|
|
|
|
};
|
|
|
|
|
|
|
|
rsaKey = mkOption {
|
|
|
|
default = null;
|
2014-08-27 21:41:15 +00:00
|
|
|
example = literalExample "/root/certificates/irc.key";
|
2009-10-12 16:36:19 +00:00
|
|
|
description = "
|
2011-09-14 18:20:50 +00:00
|
|
|
IRCD server RSA key.
|
2009-10-12 16:36:19 +00:00
|
|
|
";
|
|
|
|
};
|
|
|
|
|
|
|
|
certificate = mkOption {
|
|
|
|
default = null;
|
2014-08-27 21:41:15 +00:00
|
|
|
example = literalExample "/root/certificates/irc.pem";
|
2009-10-12 16:36:19 +00:00
|
|
|
description = "
|
|
|
|
IRCD server SSL certificate. There are some limitations - read manual.
|
|
|
|
";
|
|
|
|
};
|
|
|
|
|
|
|
|
adminEmail = mkOption {
|
|
|
|
default = "<bit-bucket@example.com>";
|
|
|
|
example = "<name@domain.tld>";
|
|
|
|
description = "
|
2011-09-14 18:20:50 +00:00
|
|
|
IRCD server administrator e-mail.
|
2009-10-12 16:36:19 +00:00
|
|
|
";
|
|
|
|
};
|
|
|
|
|
|
|
|
extraIPs = mkOption {
|
|
|
|
default = [];
|
|
|
|
example = ["127.0.0.1"];
|
|
|
|
description = "
|
|
|
|
Extra IP's to bind.
|
|
|
|
";
|
|
|
|
};
|
|
|
|
|
|
|
|
extraPort = mkOption {
|
|
|
|
default = "7117";
|
|
|
|
description = "
|
|
|
|
Extra port to avoid filtering.
|
|
|
|
";
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2009-03-06 12:26:55 +00:00
|
|
|
};
|
2009-10-12 16:36:19 +00:00
|
|
|
|
|
|
|
|
|
|
|
###### implementation
|
|
|
|
|
|
|
|
config = mkIf config.services.ircdHybrid.enable {
|
|
|
|
|
|
|
|
users.extraUsers = singleton
|
2011-09-14 18:20:50 +00:00
|
|
|
{ name = "ircd";
|
2009-10-12 16:36:19 +00:00
|
|
|
description = "IRCD owner";
|
2013-08-23 09:33:24 +00:00
|
|
|
group = "ircd";
|
|
|
|
uid = config.ids.uids.ircd;
|
2009-10-12 16:36:19 +00:00
|
|
|
};
|
|
|
|
|
2013-08-23 09:33:24 +00:00
|
|
|
users.extraGroups.ircd.gid = config.ids.gids.ircd;
|
2009-10-12 16:36:19 +00:00
|
|
|
|
2009-10-12 18:09:34 +00:00
|
|
|
jobs.ircd_hybrid =
|
2011-04-27 16:27:05 +00:00
|
|
|
{ name = "ircd-hybrid";
|
2009-10-12 16:36:19 +00:00
|
|
|
|
|
|
|
description = "IRCD Hybrid server";
|
|
|
|
|
2012-03-04 18:44:42 +00:00
|
|
|
startOn = "started networking";
|
|
|
|
stopOn = "stopping networking";
|
2009-10-12 16:36:19 +00:00
|
|
|
|
|
|
|
exec = "${ircdService}/bin/control start";
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2007-08-08 20:42:25 +00:00
|
|
|
}
|