git.iko.soy/typeable/nixpkgs
on master help sign in
Merge pull request #154805 from Lassulus/ergochat

ergochat: init at 2.9.1 (+ module/test)

commite91ed60026951707237c22b5502f283c8da9667c authorJörg Thalheim <Mic92@users.noreply.github.com> dateSat 15 Jan 2022, 12:15 (5 years ago) parent741f4a76b55249
8 files changed+291
nixos/doc/manual/from_md/release-notes/rl-2205.section.xml+7 nixos/doc/manual/release-notes/rl-2205.section.md+2 nixos/modules/module-list.nix+1 nixos/modules/services/networking/ergochat.nix+155 nixos/tests/all-tests.nix+1 nixos/tests/ergochat.nix+97 pkgs/servers/irc/ergochat/default.nix+26 pkgs/top-level/all-packages.nix+2
nixos/doc/manual/from_md/release-notes/rl-2205.section.xml+7
@@ -90,6 +90,13 @@
9090 <link xlink:href="options.html#opt-services.heisenbridge.enable">services.heisenbridge</link>.
9191 </para>
9292 </listitem>
93+ <listitem>
94+ <para>
95+ <link xlink:href="https://ergo.chat">ergochat</link>, a modern
96+ IRC with IRCv3 features. Available as
97+ <link xlink:href="options.html#opt-services.ergochat.enable">services.ergochat</link>.
98+ </para>
99+ </listitem>
93100 <listitem>
94101 <para>
95102 <link xlink:href="https://github.com/ngoduykhanh/PowerDNS-Admin">PowerDNS-Admin</link>,
nixos/doc/manual/release-notes/rl-2205.section.md+2
@@ -30,6 +30,8 @@ In addition to numerous new and upgraded packages, this release has the followin
3030
3131- [heisenbridge](https://github.com/hifi/heisenbridge), a bouncer-style Matrix IRC bridge. Available as [services.heisenbridge](options.html#opt-services.heisenbridge.enable).
3232
33+- [ergochat](https://ergo.chat), a modern IRC with IRCv3 features. Available as [services.ergochat](options.html#opt-services.ergochat.enable).
34+
3335- [PowerDNS-Admin](https://github.com/ngoduykhanh/PowerDNS-Admin), a web interface for the PowerDNS server. Available at [services.powerdns-admin](options.html#opt-services.powerdns-admin.enable).
3436
3537- [maddy](https://maddy.email), a composable all-in-one mail server. Available as [services.maddy](options.html#opt-services.maddy.enable).
nixos/modules/module-list.nix+1
@@ -740,6 +740,7 @@
740740 ./services/networking/ejabberd.nix
741741 ./services/networking/epmd.nix
742742 ./services/networking/ergo.nix
743+ ./services/networking/ergochat.nix
743744 ./services/networking/eternal-terminal.nix
744745 ./services/networking/fakeroute.nix
745746 ./services/networking/ferm.nix
nixos/modules/services/networking/ergochat.nixnew file+155
@@ -0,0 +1,155 @@
1+{ config, lib, options, pkgs, ... }: let
2+ cfg = config.services.ergochat;
3+in {
4+ options = {
5+ services.ergochat = {
6+
7+ enable = lib.mkEnableOption "Ergo IRC daemon";
8+
9+ openFilesLimit = lib.mkOption {
10+ type = lib.types.int;
11+ default = 1024;
12+ description = ''
13+ Maximum number of open files. Limits the clients and server connections.
14+ '';
15+ };
16+
17+ configFile = lib.mkOption {
18+ type = lib.types.path;
19+ default = (pkgs.formats.yaml {}).generate "ergo.conf" cfg.settings;
20+ defaultText = "generated config file from <literal>.settings</literal>";
21+ description = ''
22+ Path to configuration file.
23+ Setting this will skip any configuration done via <literal>.settings</literal>
24+ '';
25+ };
26+
27+ settings = lib.mkOption {
28+ type = (pkgs.formats.yaml {}).type;
29+ description = ''
30+ Ergo IRC daemon configuration file.
31+ https://raw.githubusercontent.com/ergochat/ergo/master/default.yaml
32+ '';
33+ default = {
34+ network = {
35+ name = "testnetwork";
36+ };
37+ server = {
38+ name = "example.com";
39+ listeners = {
40+ ":6667" = {};
41+ };
42+ casemapping = "permissive";
43+ enforce-utf = true;
44+ lookup-hostnames = false;
45+ ip-cloaking = {
46+ enabled = false;
47+ };
48+ forward-confirm-hostnames = false;
49+ check-ident = false;
50+ relaymsg = {
51+ enabled = false;
52+ };
53+ max-sendq = "1M";
54+ ip-limits = {
55+ count = false;
56+ throttle = false;
57+ };
58+ };
59+ datastore = {
60+ autoupgrade = true;
61+ # this points to the StateDirectory of the systemd service
62+ path = "/var/lib/ergo/ircd.db";
63+ };
64+ accounts = {
65+ authentication-enabled = true;
66+ registration = {
67+ enabled = true;
68+ allow-before-connect = true;
69+ throttling = {
70+ enabled = true;
71+ duration = "10m";
72+ max-attempts = 30;
73+ };
74+ bcrypt-cost = 4;
75+ email-verification.enabled = false;
76+ };
77+ multiclient = {
78+ enabled = true;
79+ allowed-by-default = true;
80+ always-on = "opt-out";
81+ auto-away = "opt-out";
82+ };
83+ };
84+ channels = {
85+ default-modes = "+ntC";
86+ registration = {
87+ enabled = true;
88+ };
89+ };
90+ limits = {
91+ nicklen = 32;
92+ identlen = 20;
93+ channellen = 64;
94+ awaylen = 390;
95+ kicklen = 390;
96+ topiclen = 390;
97+ };
98+ history = {
99+ enabled = true;
100+ channel-length = 2048;
101+ client-length = 256;
102+ autoresize-window = "3d";
103+ autoreplay-on-join = 0;
104+ chathistory-maxmessages = 100;
105+ znc-maxmessages = 2048;
106+ restrictions = {
107+ expire-time = "1w";
108+ query-cutoff = "none";
109+ grace-period = "1h";
110+ };
111+ retention = {
112+ allow-individual-delete = false;
113+ enable-account-indexing = false;
114+ };
115+ tagmsg-storage = {
116+ default = false;
117+ whitelist = [
118+ "+draft/react"
119+ "+react"
120+ ];
121+ };
122+ };
123+ };
124+ };
125+
126+ };
127+ };
128+ config = lib.mkIf cfg.enable {
129+
130+ environment.etc."ergo.yaml".source = cfg.configFile;
131+
132+ # merge configured values with default values
133+ services.ergochat.settings =
134+ lib.mapAttrsRecursive (_: lib.mkDefault) options.services.ergochat.settings.default;
135+
136+ systemd.services.ergochat = {
137+ description = "Ergo IRC daemon";
138+ wantedBy = [ "multi-user.target" ];
139+ # reload is not applying the changed config. further investigation is needed
140+ # at some point this should be enabled, since we don't want to restart for
141+ # every config change
142+ # reloadIfChanged = true;
143+ restartTriggers = [ cfg.configFile ];
144+ serviceConfig = {
145+ ExecStart = "${pkgs.ergochat}/bin/ergo run --conf /etc/ergo.yaml";
146+ ExecReload = "${pkgs.util-linux}/bin/kill -HUP $MAINPID";
147+ DynamicUser = true;
148+ StateDirectory = "ergo";
149+ LimitNOFILE = toString cfg.openFilesLimit;
150+ };
151+ };
152+
153+ };
154+ meta.maintainers = with lib.maintainers; [ lassulus tv ];
155+}
nixos/tests/all-tests.nix+1
@@ -125,6 +125,7 @@ in
125125 enlightenment = handleTest ./enlightenment.nix {};
126126 env = handleTest ./env.nix {};
127127 ergo = handleTest ./ergo.nix {};
128+ ergochat = handleTest ./ergochat.nix {};
128129 etcd = handleTestOn ["x86_64-linux"] ./etcd.nix {};
129130 etcd-cluster = handleTestOn ["x86_64-linux"] ./etcd-cluster.nix {};
130131 etebase-server = handleTest ./etebase-server.nix {};
nixos/tests/ergochat.nixnew file+97
@@ -0,0 +1,97 @@
1+let
2+ clients = [
3+ "ircclient1"
4+ "ircclient2"
5+ ];
6+ server = "ergochat";
7+ ircPort = 6667;
8+ channel = "nixos-cat";
9+ iiDir = "/tmp/irc";
10+in
11+
12+import ./make-test-python.nix ({ pkgs, lib, ... }: {
13+ name = "ergochat";
14+ nodes = {
15+ "${server}" = {
16+ networking.firewall.allowedTCPPorts = [ ircPort ];
17+ services.ergochat = {
18+ enable = true;
19+ settings.server.motd = pkgs.writeText "ergo.motd" ''
20+ The default MOTD doesn't contain the word "nixos" in it.
21+ This one does.
22+ '';
23+ };
24+ };
25+ } // lib.listToAttrs (builtins.map (client: lib.nameValuePair client {
26+ imports = [
27+ ./common/user-account.nix
28+ ];
29+
30+ systemd.services.ii = {
31+ requires = [ "network.target" ];
32+ wantedBy = [ "default.target" ];
33+
34+ serviceConfig = {
35+ Type = "simple";
36+ ExecPreStartPre = "mkdir -p ${iiDir}";
37+ ExecStart = ''
38+ ${lib.getBin pkgs.ii}/bin/ii -n ${client} -s ${server} -i ${iiDir}
39+ '';
40+ User = "alice";
41+ };
42+ };
43+ }) clients);
44+
45+ testScript =
46+ let
47+ msg = client: "Hello, my name is ${client}";
48+ clientScript = client: [
49+ ''
50+ ${client}.wait_for_unit("network.target")
51+ ${client}.systemctl("start ii")
52+ ${client}.wait_for_unit("ii")
53+ ${client}.wait_for_file("${iiDir}/${server}/out")
54+ ''
55+ # look for the custom text in the MOTD.
56+ ''
57+ ${client}.wait_until_succeeds("grep 'nixos' ${iiDir}/${server}/out")
58+ ''
59+ # wait until first PING from server arrives before joining,
60+ # so we don't try it too early
61+ ''
62+ ${client}.wait_until_succeeds("grep 'PING' ${iiDir}/${server}/out")
63+ ''
64+ # join ${channel}
65+ ''
66+ ${client}.succeed("echo '/j #${channel}' > ${iiDir}/${server}/in")
67+ ${client}.wait_for_file("${iiDir}/${server}/#${channel}/in")
68+ ''
69+ # send a greeting
70+ ''
71+ ${client}.succeed(
72+ "echo '${msg client}' > ${iiDir}/${server}/#${channel}/in"
73+ )
74+ ''
75+ # check that all greetings arrived on all clients
76+ ] ++ builtins.map (other: ''
77+ ${client}.succeed(
78+ "grep '${msg other}$' ${iiDir}/${server}/#${channel}/out"
79+ )
80+ '') clients;
81+
82+ # foldl', but requires a non-empty list instead of a start value
83+ reduce = f: list:
84+ builtins.foldl' f (builtins.head list) (builtins.tail list);
85+ in ''
86+ start_all()
87+ ${server}.systemctl("status ergochat")
88+ ${server}.wait_for_open_port(${toString ircPort})
89+
90+ # run clientScript for all clients so that every list
91+ # entry is executed by every client before advancing
92+ # to the next one.
93+ '' + lib.concatStrings
94+ (reduce
95+ (lib.zipListsWith (cs: c: cs + c))
96+ (builtins.map clientScript clients));
97+})
pkgs/servers/irc/ergochat/default.nixnew file+26
@@ -0,0 +1,26 @@
1+{ buildGo117Module, fetchFromGitHub, lib, nixosTests }:
2+
3+buildGo117Module rec {
4+ pname = "ergo";
5+ version = "2.9.1";
6+
7+ src = fetchFromGitHub {
8+ owner = "ergochat";
9+ repo = "ergo";
10+ rev = "v${version}";
11+ sha256 = "sha256-RxsmkTfHymferS/FRW0sLnstKfvGXkW6cEb/JbeS4lc=";
12+ };
13+
14+ vendorSha256 = null;
15+
16+ passthru.tests.ergochat = nixosTests.ergochat;
17+
18+ meta = {
19+ changelog = "https://github.com/ergochat/ergo/blob/v${version}/CHANGELOG.md";
20+ description = "A modern IRC server (daemon/ircd) written in Go";
21+ homepage = "https://github.com/ergochat/ergo";
22+ license = lib.licenses.mit;
23+ maintainers = with lib.maintainers; [ lassulus tv ];
24+ platforms = lib.platforms.linux;
25+ };
26+}
pkgs/top-level/all-packages.nix+2
@@ -20953,6 +20953,8 @@ with pkgs;
2095320953 gn = gn1924;
2095420954 };
2095520955
20956+ ergochat = callPackage ../servers/irc/ergochat { };
20957+
2095620958 etcd = etcd_3_3;
2095720959 etcd_3_3 = callPackage ../servers/etcd/3.3.nix { };
2095820960 etcd_3_4 = callPackage ../servers/etcd/3.4.nix { };