2024-12-10 20:26:33 +01:00
|
|
|
{
|
|
|
|
config,
|
|
|
|
lib,
|
|
|
|
pkgs,
|
|
|
|
...
|
|
|
|
}:
|
2009-03-06 12:26:55 +00:00
|
|
|
|
2014-04-14 16:26:48 +02: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";
|
2024-12-10 20:26:33 +01:00
|
|
|
scripts = [
|
|
|
|
"=>/bin"
|
|
|
|
./control.in
|
|
|
|
];
|
|
|
|
substFiles = [
|
|
|
|
"=>/conf"
|
|
|
|
./ircd.conf
|
|
|
|
];
|
|
|
|
inherit (pkgs)
|
|
|
|
ircdHybrid
|
|
|
|
coreutils
|
|
|
|
su
|
|
|
|
iproute2
|
|
|
|
gnugrep
|
|
|
|
procps
|
|
|
|
;
|
2011-04-27 16:27:05 +00:00
|
|
|
|
2017-04-11 18:08:51 +02:00
|
|
|
ipv6Enabled = boolToString config.networking.enableIPv6;
|
2011-04-27 16:27:05 +00:00
|
|
|
|
2024-12-10 20:26:33 +01:00
|
|
|
inherit (cfg)
|
|
|
|
serverName
|
|
|
|
sid
|
|
|
|
description
|
|
|
|
adminEmail
|
|
|
|
extraPort
|
|
|
|
;
|
2011-04-27 16:27:05 +00:00
|
|
|
|
2011-09-14 18:20:50 +00:00
|
|
|
cryptoSettings =
|
2024-12-10 20:26:33 +01:00
|
|
|
(optionalString (cfg.rsaKey != null) "rsa_private_key_file = \"${cfg.rsaKey}\";\n")
|
|
|
|
+ (optionalString (cfg.certificate != null) "ssl_certificate_file = \"${cfg.certificate}\";\n");
|
2011-04-27 16:27:05 +00:00
|
|
|
|
2024-12-10 20:26:33 +01:00
|
|
|
extraListen = map (
|
|
|
|
ip: "host = \"" + ip + "\";\nport = 6665 .. 6669, " + extraPort + "; "
|
|
|
|
) cfg.extraIPs;
|
2011-04-27 16:27:05 +00:00
|
|
|
|
|
|
|
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 = {
|
|
|
|
|
2024-04-13 14:54:15 +02:00
|
|
|
enable = mkEnableOption "IRCD";
|
2009-10-12 16:36:19 +00:00
|
|
|
|
|
|
|
serverName = mkOption {
|
|
|
|
default = "hades.arpa";
|
2021-01-31 11:17:03 +01:00
|
|
|
type = types.str;
|
2024-04-13 14:54:15 +02:00
|
|
|
description = ''
|
2009-10-12 16:36:19 +00:00
|
|
|
IRCD server name.
|
2022-08-14 05:16:55 +02:00
|
|
|
'';
|
2009-10-12 16:36:19 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
sid = mkOption {
|
|
|
|
default = "0NL";
|
2021-01-31 11:17:03 +01:00
|
|
|
type = types.str;
|
2024-04-13 14:54:15 +02:00
|
|
|
description = ''
|
2009-10-12 16:36:19 +00:00
|
|
|
IRCD server unique ID in a net of servers.
|
2022-08-14 05:16:55 +02:00
|
|
|
'';
|
2009-10-12 16:36:19 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
description = mkOption {
|
|
|
|
default = "Hybrid-7 IRC server.";
|
2021-01-31 11:17:03 +01:00
|
|
|
type = types.str;
|
2024-04-13 14:54:15 +02:00
|
|
|
description = ''
|
2009-10-12 16:36:19 +00:00
|
|
|
IRCD server description.
|
2022-08-14 05:16:55 +02:00
|
|
|
'';
|
2009-10-12 16:36:19 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
rsaKey = mkOption {
|
|
|
|
default = null;
|
2021-10-03 18:06:03 +02:00
|
|
|
example = literalExpression "/root/certificates/irc.key";
|
2021-01-31 11:17:03 +01:00
|
|
|
type = types.nullOr types.path;
|
2024-04-13 14:54:15 +02:00
|
|
|
description = ''
|
2011-09-14 18:20:50 +00:00
|
|
|
IRCD server RSA key.
|
2022-08-14 05:16:55 +02:00
|
|
|
'';
|
2009-10-12 16:36:19 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
certificate = mkOption {
|
|
|
|
default = null;
|
2021-10-03 18:06:03 +02:00
|
|
|
example = literalExpression "/root/certificates/irc.pem";
|
2021-01-31 11:17:03 +01:00
|
|
|
type = types.nullOr types.path;
|
2024-04-13 14:54:15 +02:00
|
|
|
description = ''
|
2009-10-12 16:36:19 +00:00
|
|
|
IRCD server SSL certificate. There are some limitations - read manual.
|
2022-08-14 05:16:55 +02:00
|
|
|
'';
|
2009-10-12 16:36:19 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
adminEmail = mkOption {
|
|
|
|
default = "<bit-bucket@example.com>";
|
2021-01-31 11:17:03 +01:00
|
|
|
type = types.str;
|
2009-10-12 16:36:19 +00:00
|
|
|
example = "<name@domain.tld>";
|
2024-04-13 14:54:15 +02:00
|
|
|
description = ''
|
2011-09-14 18:20:50 +00:00
|
|
|
IRCD server administrator e-mail.
|
2022-08-14 05:16:55 +02:00
|
|
|
'';
|
2009-10-12 16:36:19 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
extraIPs = mkOption {
|
2024-12-10 20:26:33 +01:00
|
|
|
default = [ ];
|
|
|
|
example = [ "127.0.0.1" ];
|
2021-01-31 11:17:03 +01:00
|
|
|
type = types.listOf types.str;
|
2024-04-13 14:54:15 +02:00
|
|
|
description = ''
|
2009-10-12 16:36:19 +00:00
|
|
|
Extra IP's to bind.
|
2022-08-14 05:16:55 +02:00
|
|
|
'';
|
2009-10-12 16:36:19 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
extraPort = mkOption {
|
|
|
|
default = "7117";
|
2021-01-31 11:17:03 +01:00
|
|
|
type = types.str;
|
2024-04-13 14:54:15 +02:00
|
|
|
description = ''
|
2009-10-12 16:36:19 +00:00
|
|
|
Extra port to avoid filtering.
|
2022-08-14 05:16:55 +02:00
|
|
|
'';
|
2009-10-12 16:36:19 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2009-03-06 12:26:55 +00:00
|
|
|
};
|
2009-10-12 16:36:19 +00:00
|
|
|
|
|
|
|
###### implementation
|
|
|
|
|
|
|
|
config = mkIf config.services.ircdHybrid.enable {
|
|
|
|
|
2024-12-10 20:26:33 +01:00
|
|
|
users.users.ircd = {
|
|
|
|
description = "IRCD owner";
|
|
|
|
group = "ircd";
|
|
|
|
uid = config.ids.uids.ircd;
|
|
|
|
};
|
2009-10-12 16:36:19 +00:00
|
|
|
|
2018-06-30 01:58:35 +02:00
|
|
|
users.groups.ircd.gid = config.ids.gids.ircd;
|
2009-10-12 16:36:19 +00:00
|
|
|
|
2019-08-13 21:52:01 +00:00
|
|
|
systemd.services.ircd-hybrid = {
|
2016-01-06 06:50:18 +00:00
|
|
|
description = "IRCD Hybrid server";
|
2023-10-03 22:52:00 -07:00
|
|
|
wants = [ "network-online.target" ];
|
|
|
|
after = [ "network-online.target" ];
|
2016-01-06 06:50:18 +00:00
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
script = "${ircdService}/bin/control start";
|
|
|
|
};
|
2009-10-12 16:36:19 +00:00
|
|
|
};
|
2007-08-08 20:42:25 +00:00
|
|
|
}
|