1 { lib, pkgs, config, mypackages-lib, ... }:
3 cfg = config.myServices.ejabberd;
7 ejabberd.enable = lib.mkOption {
11 Whether to enable ejabberd service.
16 config = lib.mkIf cfg.enable {
17 myServices.dns.zones."immae.fr" = with config.myServices.dns.helpers;
24 emailPolicies."".receive = true;
28 (mailCommon "immae.fr" true)
29 (ips servers.eldiron.ips.main)
31 ns = [ "immae" "raito" ];
33 subdomains.www = ips servers.eldiron.ips.production;
34 subdomains.im = ips servers.eldiron.ips.main;
35 subdomains.conference = ips servers.eldiron.ips.main;
36 subdomains.pubsub = ips servers.eldiron.ips.main;
37 subdomains.proxy = ips servers.eldiron.ips.main;
38 subdomains.upload = ips servers.eldiron.ips.main;
39 subdomains._xmppconnect.TXT = [
40 "_xmpp-client-xbosh=https://im.immae.fr/bosh"
41 "_xmpp-client-websocket=wss://im.immae.fr/ws"
46 security.acme.certs = {
49 domain = "eldiron.immae.eu";
52 systemctl restart ejabberd.service
54 extraDomainNames = [ "immae.fr" "conference.immae.fr" "proxy.immae.fr" "pubsub.immae.fr" "upload.immae.fr" ];
57 networking.firewall.allowedTCPPorts = [ 5222 5269 ];
58 myServices.websites.tools.im.enable = true;
59 systemd.services.ejabberd.postStop = ''
60 rm /var/log/ejabberd/erl_crash*.dump
63 "ejabberd/psql.yml" = {
69 sql_server: "localhost"
70 sql_database: "${config.myEnv.jabber.postgresql.database}"
71 sql_username: "${config.myEnv.jabber.postgresql.user}"
72 sql_password: "${config.myEnv.jabber.postgresql.password}"
75 "ejabberd/host.yml" = {
82 domain_certfile: "${config.security.acme.certs.ejabberd.directory}/full.pem"
84 ldap_servers: ["${config.myEnv.jabber.ldap.host}"]
86 ldap_rootdn: "${config.myEnv.jabber.ldap.dn}"
87 ldap_password: "${config.myEnv.jabber.ldap.password}"
88 ldap_base: "${config.myEnv.jabber.ldap.base}"
92 ldap_filter: "${config.myEnv.jabber.ldap.filter}"
96 users.users.ejabberd.extraGroups = [ "keys" ];
98 package = pkgs.ejabberd.override { withPgsql = true; };
102 ERLANG_NODE=ejabberd@localhost
104 configFile = pkgs.runCommand "ejabberd.yml" {
105 certificatePrivateKeyAndFullChain = "${config.security.acme.certs.ejabberd.directory}/full.pem";
106 certificateCA = "${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt";
107 sql_config_file = config.secrets.fullPaths."ejabberd/psql.yml";
108 host_config_file = config.secrets.fullPaths."ejabberd/host.yml";
110 substituteAll ${./ejabberd.yml} $out
113 secrets.keys."postfix/scripts/ejabberd-env" = {
114 user = "postfixscripts";
116 permissions = "0400";
117 text = builtins.toJSON {
118 jid = "notify_bot@immae.fr";
119 password = "{{ .xmpp.notify_bot }}";
122 services.postfix.extraAliases = let
123 nixpkgs = builtins.fetchTarball {
124 url = "https://github.com/NixOS/nixpkgs/archive/840c782d507d60aaa49aa9e3f6d0b0e780912742.tar.gz";
125 sha256 = "14q3kvnmgz19pgwyq52gxx0cs90ddf24pnplmq33pdddbb6c51zn";
127 pkgs' = import nixpkgs { inherit (pkgs) system; overlays = []; };
128 warn_xmpp_email = scriptEnv: pkgs'.runCommand "warn_xmpp_email" {
130 pythonEnv = pkgs'.python3.withPackages (ps: [
131 ps.unidecode ps.slixmpp
134 substituteAll ${./warn_xmpp_email.py} $out
138 ejabberd: "|${mypackages-lib.postfixScript pkgs "ejabberd" (warn_xmpp_email config.secrets.fullPaths."postfix/scripts/ejabberd-env")}"