nixos/modules/inspircd: add simplistic module and nixos test
This commit is contained in:
parent
0fd939c6ea
commit
4048b39fc1
|
@ -682,6 +682,7 @@
|
||||||
./services/networking/i2p.nix
|
./services/networking/i2p.nix
|
||||||
./services/networking/icecream/scheduler.nix
|
./services/networking/icecream/scheduler.nix
|
||||||
./services/networking/icecream/daemon.nix
|
./services/networking/icecream/daemon.nix
|
||||||
|
./services/networking/inspircd.nix
|
||||||
./services/networking/iodine.nix
|
./services/networking/iodine.nix
|
||||||
./services/networking/iperf3.nix
|
./services/networking/iperf3.nix
|
||||||
./services/networking/ircd-hybrid/default.nix
|
./services/networking/ircd-hybrid/default.nix
|
||||||
|
|
|
@ -0,0 +1,58 @@
|
||||||
|
{ config, lib, pkgs, ... }:
|
||||||
|
|
||||||
|
let
|
||||||
|
cfg = config.services.inspircd;
|
||||||
|
|
||||||
|
configFile = pkgs.writeText "inspircd.conf" cfg.config;
|
||||||
|
|
||||||
|
in {
|
||||||
|
options = {
|
||||||
|
services.inspircd = {
|
||||||
|
enable = lib.mkEnableOption "InspIRCd";
|
||||||
|
|
||||||
|
package = lib.mkOption {
|
||||||
|
type = lib.types.package;
|
||||||
|
default = pkgs.inspircd;
|
||||||
|
defaultText = lib.literalExample "pkgs.inspircd";
|
||||||
|
example = lib.literalExample "pkgs.inspircdMinimal";
|
||||||
|
description = ''
|
||||||
|
The InspIRCd package to use. This is mainly useful
|
||||||
|
to specify an overridden version of the
|
||||||
|
<literal>pkgs.inspircd</literal> 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 <literal>inspircd.conf</literal> file.
|
||||||
|
For a list of options, consult the
|
||||||
|
<link xlink:href="https://docs.inspircd.org/3/configuration/">InspIRCd documentation</link>, the
|
||||||
|
<link xlink:href="https://docs.inspircd.org/3/modules/">Module documentation</link>
|
||||||
|
and the example configuration files distributed
|
||||||
|
with <literal>pkgs.inspircd.doc</literal>
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
config = lib.mkIf cfg.enable {
|
||||||
|
systemd.services.inspircd = {
|
||||||
|
description = "InspIRCd - the stable, high-performance and modular Internet Relay Chat Daemon";
|
||||||
|
wantedBy = [ "multi-user.target" ];
|
||||||
|
requires = [ "network.target" ];
|
||||||
|
|
||||||
|
serviceConfig = {
|
||||||
|
Type = "simple";
|
||||||
|
ExecStart = ''
|
||||||
|
${lib.getBin cfg.package}/bin/inspircd start --config ${configFile} --nofork --nopid
|
||||||
|
'';
|
||||||
|
DynamicUser = true;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
|
@ -176,6 +176,7 @@ in
|
||||||
initrd-network-ssh = handleTest ./initrd-network-ssh {};
|
initrd-network-ssh = handleTest ./initrd-network-ssh {};
|
||||||
initrdNetwork = handleTest ./initrd-network.nix {};
|
initrdNetwork = handleTest ./initrd-network.nix {};
|
||||||
initrd-secrets = handleTest ./initrd-secrets.nix {};
|
initrd-secrets = handleTest ./initrd-secrets.nix {};
|
||||||
|
inspircd = handleTest ./inspircd.nix {};
|
||||||
installer = handleTest ./installer.nix {};
|
installer = handleTest ./installer.nix {};
|
||||||
iodine = handleTest ./iodine.nix {};
|
iodine = handleTest ./iodine.nix {};
|
||||||
ipfs = handleTest ./ipfs.nix {};
|
ipfs = handleTest ./ipfs.nix {};
|
||||||
|
|
|
@ -0,0 +1,96 @@
|
||||||
|
let
|
||||||
|
clients = [
|
||||||
|
"ircclient1"
|
||||||
|
"ircclient2"
|
||||||
|
];
|
||||||
|
server = "inspircd";
|
||||||
|
ircPort = 6667;
|
||||||
|
channel = "nixos-cat";
|
||||||
|
iiDir = "/tmp/irc";
|
||||||
|
in
|
||||||
|
|
||||||
|
import ./make-test-python.nix ({ pkgs, lib, ... }: {
|
||||||
|
name = "inspircd";
|
||||||
|
nodes = {
|
||||||
|
"${server}" = {
|
||||||
|
networking.firewall.allowedTCPPorts = [ ircPort ];
|
||||||
|
services.inspircd = {
|
||||||
|
enable = true;
|
||||||
|
package = pkgs.inspircdMinimal;
|
||||||
|
config = ''
|
||||||
|
<bind address="" port="${toString ircPort}" type="clients">
|
||||||
|
<connect name="main" allow="*" pingfreq="15">
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
} // lib.listToAttrs (builtins.map (client: lib.nameValuePair client {
|
||||||
|
imports = [
|
||||||
|
./common/user-account.nix
|
||||||
|
];
|
||||||
|
|
||||||
|
systemd.services.ii = {
|
||||||
|
requires = [ "network.target" ];
|
||||||
|
wantedBy = [ "default.target" ];
|
||||||
|
|
||||||
|
serviceConfig = {
|
||||||
|
Type = "simple";
|
||||||
|
ExecPreStartPre = "mkdir -p ${iiDir}";
|
||||||
|
ExecStart = ''
|
||||||
|
${lib.getBin pkgs.ii}/bin/ii -n ${client} -s ${server} -i ${iiDir}
|
||||||
|
'';
|
||||||
|
User = "alice";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}) clients);
|
||||||
|
|
||||||
|
testScript =
|
||||||
|
let
|
||||||
|
msg = client: "Hello, my name is ${client}";
|
||||||
|
clientScript = client: [
|
||||||
|
''
|
||||||
|
${client}.wait_for_unit("network.target")
|
||||||
|
${client}.systemctl("start ii")
|
||||||
|
${client}.wait_for_unit("ii")
|
||||||
|
${client}.wait_for_file("${iiDir}/${server}/out")
|
||||||
|
''
|
||||||
|
# wait until first PING from server arrives before joining,
|
||||||
|
# so we don't try it too early
|
||||||
|
''
|
||||||
|
${client}.wait_until_succeeds("grep 'PING' ${iiDir}/${server}/out")
|
||||||
|
''
|
||||||
|
# join ${channel}
|
||||||
|
''
|
||||||
|
${client}.succeed("echo '/j #${channel}' > ${iiDir}/${server}/in")
|
||||||
|
${client}.wait_for_file("${iiDir}/${server}/#${channel}/in")
|
||||||
|
''
|
||||||
|
# send a greeting
|
||||||
|
''
|
||||||
|
${client}.succeed(
|
||||||
|
"echo '${msg client}' > ${iiDir}/${server}/#${channel}/in"
|
||||||
|
)
|
||||||
|
''
|
||||||
|
# check that all greetings arrived on all clients
|
||||||
|
] ++ builtins.map (other: ''
|
||||||
|
${client}.succeed(
|
||||||
|
"grep '${msg other}$' ${iiDir}/${server}/#${channel}/out"
|
||||||
|
)
|
||||||
|
'') clients ++ [
|
||||||
|
"# trailing comment to please reformatter :)"
|
||||||
|
];
|
||||||
|
|
||||||
|
# foldl', but requires a non-empty list instead of a start value
|
||||||
|
reduce = f: list:
|
||||||
|
builtins.foldl' f (builtins.head list) (builtins.tail list);
|
||||||
|
in ''
|
||||||
|
start_all()
|
||||||
|
${server}.wait_for_open_port(${toString ircPort})
|
||||||
|
|
||||||
|
# run clientScript for all clients so that every list
|
||||||
|
# entry is executed by every client before advancing
|
||||||
|
# to the next one.
|
||||||
|
${lib.concatStringsSep "\n"
|
||||||
|
(reduce
|
||||||
|
(a: b: lib.zipListsWith (cs: c: cs + "\n" + c) a b)
|
||||||
|
(builtins.map clientScript clients))}
|
||||||
|
'';
|
||||||
|
})
|
Loading…
Reference in New Issue