2014-09-02 17:08:56 +02:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
let
|
|
|
|
cfg = config.services.prosody;
|
|
|
|
|
|
|
|
sslOpts = { ... }: {
|
|
|
|
|
|
|
|
options = {
|
|
|
|
|
|
|
|
key = mkOption {
|
2017-03-01 01:57:02 +01:00
|
|
|
type = types.path;
|
2017-03-01 01:57:02 +01:00
|
|
|
description = "Path to the key file.";
|
2014-09-02 17:08:56 +02:00
|
|
|
};
|
|
|
|
|
2017-12-22 01:17:48 +01:00
|
|
|
# TODO: rename to certificate to match the prosody config
|
2014-09-02 17:08:56 +02:00
|
|
|
cert = mkOption {
|
2017-03-01 01:57:02 +01:00
|
|
|
type = types.path;
|
2017-03-01 01:57:02 +01:00
|
|
|
description = "Path to the certificate file.";
|
|
|
|
};
|
|
|
|
|
|
|
|
extraOptions = mkOption {
|
|
|
|
type = types.attrs;
|
|
|
|
default = {};
|
|
|
|
description = "Extra SSL configuration options.";
|
2014-09-02 17:08:56 +02:00
|
|
|
};
|
2017-03-01 01:57:02 +01:00
|
|
|
|
2014-09-02 17:08:56 +02:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2020-04-20 20:27:53 +02:00
|
|
|
discoOpts = {
|
|
|
|
options = {
|
|
|
|
url = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
description = "URL of the endpoint you want to make discoverable";
|
|
|
|
};
|
|
|
|
description = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
description = "A short description of the endpoint you want to advertise";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2014-09-02 17:08:56 +02:00
|
|
|
moduleOpts = {
|
2020-04-20 20:27:53 +02:00
|
|
|
# Required for compliance with https://compliance.conversations.im/about/
|
2014-09-02 17:08:56 +02:00
|
|
|
roster = mkOption {
|
2017-03-01 01:57:02 +01:00
|
|
|
type = types.bool;
|
2014-09-02 17:08:56 +02:00
|
|
|
default = true;
|
|
|
|
description = "Allow users to have a roster";
|
|
|
|
};
|
|
|
|
|
|
|
|
saslauth = mkOption {
|
2017-03-01 01:57:02 +01:00
|
|
|
type = types.bool;
|
2014-09-02 17:08:56 +02:00
|
|
|
default = true;
|
|
|
|
description = "Authentication for clients and servers. Recommended if you want to log in.";
|
|
|
|
};
|
|
|
|
|
|
|
|
tls = mkOption {
|
2017-03-01 01:57:02 +01:00
|
|
|
type = types.bool;
|
2014-09-02 17:08:56 +02:00
|
|
|
default = true;
|
|
|
|
description = "Add support for secure TLS on c2s/s2s connections";
|
|
|
|
};
|
|
|
|
|
|
|
|
dialback = mkOption {
|
2017-03-01 01:57:02 +01:00
|
|
|
type = types.bool;
|
2014-09-02 17:08:56 +02:00
|
|
|
default = true;
|
|
|
|
description = "s2s dialback support";
|
|
|
|
};
|
|
|
|
|
|
|
|
disco = mkOption {
|
2017-03-01 01:57:02 +01:00
|
|
|
type = types.bool;
|
2014-09-02 17:08:56 +02:00
|
|
|
default = true;
|
|
|
|
description = "Service discovery";
|
|
|
|
};
|
|
|
|
|
2017-12-22 01:17:48 +01:00
|
|
|
# Not essential, but recommended
|
|
|
|
carbons = mkOption {
|
2017-03-01 01:57:02 +01:00
|
|
|
type = types.bool;
|
2014-09-02 17:08:56 +02:00
|
|
|
default = true;
|
2017-12-22 01:17:48 +01:00
|
|
|
description = "Keep multiple clients in sync";
|
|
|
|
};
|
|
|
|
|
2020-04-20 20:27:53 +02:00
|
|
|
csi = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = true;
|
|
|
|
description = "Implements the CSI protocol that allows clients to report their active/inactive state to the server";
|
|
|
|
};
|
|
|
|
|
|
|
|
cloud_notify = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = true;
|
|
|
|
description = "Push notifications to inform users of new messages or other pertinent information even when they have no XMPP clients online";
|
|
|
|
};
|
|
|
|
|
2017-12-22 01:17:48 +01:00
|
|
|
pep = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = true;
|
|
|
|
description = "Enables users to publish their mood, activity, playing music and more";
|
2014-09-02 17:08:56 +02:00
|
|
|
};
|
|
|
|
|
2017-12-22 01:17:48 +01:00
|
|
|
private = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = true;
|
|
|
|
description = "Private XML storage (for room bookmarks, etc.)";
|
|
|
|
};
|
|
|
|
|
|
|
|
blocklist = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = true;
|
|
|
|
description = "Allow users to block communications with other users";
|
|
|
|
};
|
|
|
|
|
|
|
|
vcard = mkOption {
|
|
|
|
type = types.bool;
|
2020-04-20 20:27:53 +02:00
|
|
|
default = false;
|
2017-12-22 01:17:48 +01:00
|
|
|
description = "Allow users to set vCards";
|
|
|
|
};
|
|
|
|
|
2020-04-20 20:27:53 +02:00
|
|
|
vcard_legacy = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = true;
|
|
|
|
description = "Converts users profiles and Avatars between old and new formats";
|
|
|
|
};
|
|
|
|
|
|
|
|
bookmarks = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = true;
|
|
|
|
description = "Allows interop between older clients that use XEP-0048: Bookmarks in its 1.0 version and recent clients which use it in PEP";
|
|
|
|
};
|
|
|
|
|
2017-12-22 01:17:48 +01:00
|
|
|
# Nice to have
|
2014-09-02 17:08:56 +02:00
|
|
|
version = mkOption {
|
2017-03-01 01:57:02 +01:00
|
|
|
type = types.bool;
|
2014-09-02 17:08:56 +02:00
|
|
|
default = true;
|
|
|
|
description = "Replies to server version requests";
|
|
|
|
};
|
|
|
|
|
|
|
|
uptime = mkOption {
|
2017-03-01 01:57:02 +01:00
|
|
|
type = types.bool;
|
2014-09-02 17:08:56 +02:00
|
|
|
default = true;
|
|
|
|
description = "Report how long server has been running";
|
|
|
|
};
|
|
|
|
|
|
|
|
time = mkOption {
|
2017-03-01 01:57:02 +01:00
|
|
|
type = types.bool;
|
2014-09-02 17:08:56 +02:00
|
|
|
default = true;
|
|
|
|
description = "Let others know the time here on this server";
|
|
|
|
};
|
|
|
|
|
|
|
|
ping = mkOption {
|
2017-03-01 01:57:02 +01:00
|
|
|
type = types.bool;
|
2014-09-02 17:08:56 +02:00
|
|
|
default = true;
|
|
|
|
description = "Replies to XMPP pings with pongs";
|
|
|
|
};
|
|
|
|
|
2017-12-22 01:17:48 +01:00
|
|
|
register = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = true;
|
|
|
|
description = "Allow users to register on this server using a client and change passwords";
|
|
|
|
};
|
|
|
|
|
|
|
|
mam = mkOption {
|
|
|
|
type = types.bool;
|
2020-04-20 20:27:53 +02:00
|
|
|
default = true;
|
2017-12-22 01:17:48 +01:00
|
|
|
description = "Store messages in an archive and allow users to access it";
|
|
|
|
};
|
|
|
|
|
2020-04-20 20:27:53 +02:00
|
|
|
smacks = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = true;
|
|
|
|
description = "Allow a client to resume a disconnected session, and prevent message loss";
|
|
|
|
};
|
|
|
|
|
2017-12-22 01:17:48 +01:00
|
|
|
# Admin interfaces
|
|
|
|
admin_adhoc = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = true;
|
|
|
|
description = "Allows administration via an XMPP client that supports ad-hoc commands";
|
|
|
|
};
|
|
|
|
|
2020-04-20 20:27:53 +02:00
|
|
|
http_files = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = true;
|
|
|
|
description = "Serve static files from a directory over HTTP";
|
|
|
|
};
|
|
|
|
|
|
|
|
proxy65 = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = true;
|
|
|
|
description = "Enables a file transfer proxy service which clients behind NAT can use";
|
|
|
|
};
|
|
|
|
|
2017-12-22 01:17:48 +01:00
|
|
|
admin_telnet = mkOption {
|
2017-03-01 01:57:02 +01:00
|
|
|
type = types.bool;
|
2014-09-02 17:08:56 +02:00
|
|
|
default = false;
|
2017-12-22 01:17:48 +01:00
|
|
|
description = "Opens telnet console interface on localhost port 5582";
|
2014-09-02 17:08:56 +02:00
|
|
|
};
|
|
|
|
|
2017-12-22 01:17:48 +01:00
|
|
|
# HTTP modules
|
2014-09-02 17:08:56 +02:00
|
|
|
bosh = mkOption {
|
2017-03-01 01:57:02 +01:00
|
|
|
type = types.bool;
|
2014-09-02 17:08:56 +02:00
|
|
|
default = false;
|
|
|
|
description = "Enable BOSH clients, aka 'Jabber over HTTP'";
|
|
|
|
};
|
|
|
|
|
2017-12-22 01:17:48 +01:00
|
|
|
websocket = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = false;
|
|
|
|
description = "Enable WebSocket support";
|
|
|
|
};
|
|
|
|
|
|
|
|
# Other specific functionality
|
|
|
|
limits = mkOption {
|
2017-03-01 01:57:02 +01:00
|
|
|
type = types.bool;
|
2014-10-15 03:57:00 +02:00
|
|
|
default = false;
|
2017-12-22 01:17:48 +01:00
|
|
|
description = "Enable bandwidth limiting for XMPP connections";
|
|
|
|
};
|
|
|
|
|
|
|
|
groups = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = false;
|
|
|
|
description = "Shared roster support";
|
|
|
|
};
|
|
|
|
|
|
|
|
server_contact_info = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = false;
|
|
|
|
description = "Publish contact information for this service";
|
|
|
|
};
|
|
|
|
|
|
|
|
announce = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = false;
|
|
|
|
description = "Send announcement to all online users";
|
|
|
|
};
|
|
|
|
|
|
|
|
welcome = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = false;
|
|
|
|
description = "Welcome users who register accounts";
|
|
|
|
};
|
|
|
|
|
|
|
|
watchregistrations = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = false;
|
|
|
|
description = "Alert admins of registrations";
|
|
|
|
};
|
|
|
|
|
|
|
|
motd = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = false;
|
|
|
|
description = "Send a message to users when they log in";
|
|
|
|
};
|
|
|
|
|
|
|
|
legacyauth = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = false;
|
|
|
|
description = "Legacy authentication. Only used by some old clients and bots";
|
|
|
|
};
|
2014-09-02 17:08:56 +02:00
|
|
|
};
|
|
|
|
|
2017-03-01 01:57:02 +01:00
|
|
|
toLua = x:
|
|
|
|
if builtins.isString x then ''"${x}"''
|
2020-10-14 01:46:17 +02:00
|
|
|
else if builtins.isBool x then boolToString x
|
2017-03-01 01:57:02 +01:00
|
|
|
else if builtins.isInt x then toString x
|
2017-12-22 01:17:48 +01:00
|
|
|
else if builtins.isList x then ''{ ${lib.concatStringsSep ", " (map (n: toLua n) x) } }''
|
2017-03-01 01:57:02 +01:00
|
|
|
else throw "Invalid Lua value";
|
|
|
|
|
|
|
|
createSSLOptsStr = o: ''
|
|
|
|
ssl = {
|
2018-04-26 11:12:36 +02:00
|
|
|
cafile = "/etc/ssl/certs/ca-bundle.crt";
|
2017-03-01 01:57:02 +01:00
|
|
|
key = "${o.key}";
|
|
|
|
certificate = "${o.cert}";
|
|
|
|
${concatStringsSep "\n" (mapAttrsToList (name: value: "${name} = ${toLua value};") o.extraOptions)}
|
|
|
|
};
|
|
|
|
'';
|
2014-09-02 17:08:56 +02:00
|
|
|
|
2020-04-20 20:27:53 +02:00
|
|
|
mucOpts = { ... }: {
|
|
|
|
options = {
|
|
|
|
domain = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
description = "Domain name of the MUC";
|
|
|
|
};
|
|
|
|
name = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
description = "The name to return in service discovery responses for the MUC service itself";
|
|
|
|
default = "Prosody Chatrooms";
|
|
|
|
};
|
|
|
|
restrictRoomCreation = mkOption {
|
|
|
|
type = types.enum [ true false "admin" "local" ];
|
|
|
|
default = false;
|
|
|
|
description = "Restrict room creation to server admins";
|
|
|
|
};
|
|
|
|
maxHistoryMessages = mkOption {
|
|
|
|
type = types.int;
|
|
|
|
default = 20;
|
|
|
|
description = "Specifies a limit on what each room can be configured to keep";
|
|
|
|
};
|
|
|
|
roomLocking = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = true;
|
|
|
|
description = ''
|
|
|
|
Enables room locking, which means that a room must be
|
|
|
|
configured before it can be used. Locked rooms are invisible
|
|
|
|
and cannot be entered by anyone but the creator
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
roomLockTimeout = mkOption {
|
|
|
|
type = types.int;
|
|
|
|
default = 300;
|
|
|
|
description = ''
|
|
|
|
Timout after which the room is destroyed or unlocked if not
|
|
|
|
configured, in seconds
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
tombstones = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = true;
|
|
|
|
description = ''
|
|
|
|
When a room is destroyed, it leaves behind a tombstone which
|
|
|
|
prevents the room being entered or recreated. It also allows
|
|
|
|
anyone who was not in the room at the time it was destroyed
|
|
|
|
to learn about it, and to update their bookmarks. Tombstones
|
|
|
|
prevents the case where someone could recreate a previously
|
|
|
|
semi-anonymous room in order to learn the real JIDs of those
|
|
|
|
who often join there.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
tombstoneExpiry = mkOption {
|
|
|
|
type = types.int;
|
|
|
|
default = 2678400;
|
|
|
|
description = ''
|
|
|
|
This settings controls how long a tombstone is considered
|
|
|
|
valid. It defaults to 31 days. After this time, the room in
|
|
|
|
question can be created again.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
vcard_muc = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = true;
|
|
|
|
description = "Adds the ability to set vCard for Multi User Chat rooms";
|
|
|
|
};
|
|
|
|
|
|
|
|
# Extra parameters. Defaulting to prosody default values.
|
|
|
|
# Adding them explicitly to make them visible from the options
|
|
|
|
# documentation.
|
|
|
|
#
|
|
|
|
# See https://prosody.im/doc/modules/mod_muc for more details.
|
|
|
|
roomDefaultPublic = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = true;
|
|
|
|
description = "If set, the MUC rooms will be public by default.";
|
|
|
|
};
|
|
|
|
roomDefaultMembersOnly = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = false;
|
|
|
|
description = "If set, the MUC rooms will only be accessible to the members by default.";
|
|
|
|
};
|
|
|
|
roomDefaultModerated = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = false;
|
|
|
|
description = "If set, the MUC rooms will be moderated by default.";
|
|
|
|
};
|
|
|
|
roomDefaultPublicJids = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = false;
|
|
|
|
description = "If set, the MUC rooms will display the public JIDs by default.";
|
|
|
|
};
|
|
|
|
roomDefaultChangeSubject = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = false;
|
|
|
|
description = "If set, the rooms will display the public JIDs by default.";
|
|
|
|
};
|
|
|
|
roomDefaultHistoryLength = mkOption {
|
|
|
|
type = types.int;
|
|
|
|
default = 20;
|
|
|
|
description = "Number of history message sent to participants by default.";
|
|
|
|
};
|
|
|
|
roomDefaultLanguage = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "en";
|
|
|
|
description = "Default room language.";
|
|
|
|
};
|
2020-05-04 00:10:33 +02:00
|
|
|
extraConfig = mkOption {
|
|
|
|
type = types.lines;
|
|
|
|
default = "";
|
|
|
|
description = "Additional MUC specific configuration";
|
|
|
|
};
|
2020-04-20 20:27:53 +02:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
uploadHttpOpts = { ... }: {
|
|
|
|
options = {
|
|
|
|
domain = mkOption {
|
|
|
|
type = types.nullOr types.str;
|
|
|
|
description = "Domain name for the http-upload service";
|
|
|
|
};
|
|
|
|
uploadFileSizeLimit = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "50 * 1024 * 1024";
|
|
|
|
description = "Maximum file size, in bytes. Defaults to 50MB.";
|
|
|
|
};
|
|
|
|
uploadExpireAfter = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "60 * 60 * 24 * 7";
|
|
|
|
description = "Max age of a file before it gets deleted, in seconds.";
|
|
|
|
};
|
|
|
|
userQuota = mkOption {
|
|
|
|
type = types.nullOr types.int;
|
|
|
|
default = null;
|
|
|
|
example = 1234;
|
|
|
|
description = ''
|
|
|
|
Maximum size of all uploaded files per user, in bytes. There
|
|
|
|
will be no quota if this option is set to null.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
httpUploadPath = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
description = ''
|
|
|
|
Directory where the uploaded files will be stored. By
|
|
|
|
default, uploaded files are put in a sub-directory of the
|
|
|
|
default Prosody storage path (usually /var/lib/prosody).
|
|
|
|
'';
|
|
|
|
default = "/var/lib/prosody";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2014-09-02 17:08:56 +02:00
|
|
|
vHostOpts = { ... }: {
|
|
|
|
|
|
|
|
options = {
|
|
|
|
|
|
|
|
# TODO: require attribute
|
|
|
|
domain = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
description = "Domain name";
|
|
|
|
};
|
|
|
|
|
2015-03-30 13:45:07 +02:00
|
|
|
enabled = mkOption {
|
2017-03-01 01:57:02 +01:00
|
|
|
type = types.bool;
|
2014-09-02 17:08:56 +02:00
|
|
|
default = false;
|
|
|
|
description = "Whether to enable the virtual host";
|
|
|
|
};
|
|
|
|
|
|
|
|
ssl = mkOption {
|
2017-03-01 01:57:02 +01:00
|
|
|
type = types.nullOr (types.submodule sslOpts);
|
2014-09-02 17:08:56 +02:00
|
|
|
default = null;
|
2017-03-01 01:57:02 +01:00
|
|
|
description = "Paths to SSL files";
|
2014-09-02 17:08:56 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
extraConfig = mkOption {
|
2017-03-01 01:57:02 +01:00
|
|
|
type = types.lines;
|
|
|
|
default = "";
|
2014-09-02 17:08:56 +02:00
|
|
|
description = "Additional virtual host specific configuration";
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
in
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
###### interface
|
|
|
|
|
|
|
|
options = {
|
|
|
|
|
|
|
|
services.prosody = {
|
|
|
|
|
|
|
|
enable = mkOption {
|
2017-03-01 01:57:02 +01:00
|
|
|
type = types.bool;
|
2014-09-02 17:08:56 +02:00
|
|
|
default = false;
|
|
|
|
description = "Whether to enable the prosody server";
|
|
|
|
};
|
|
|
|
|
2020-04-20 20:27:53 +02:00
|
|
|
xmppComplianceSuite = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = true;
|
|
|
|
description = ''
|
|
|
|
The XEP-0423 defines a set of recommended XEPs to implement
|
|
|
|
for a server. It's generally a good idea to implement this
|
|
|
|
set of extensions if you want to provide your users with a
|
|
|
|
good XMPP experience.
|
|
|
|
|
|
|
|
This NixOS module aims to provide a "advanced server"
|
|
|
|
experience as per defined in the XEP-0423[1] specification.
|
|
|
|
|
|
|
|
Setting this option to true will prevent you from building a
|
|
|
|
NixOS configuration which won't comply with this standard.
|
|
|
|
You can explicitely decide to ignore this standard if you
|
|
|
|
know what you are doing by setting this option to false.
|
|
|
|
|
|
|
|
[1] https://xmpp.org/extensions/xep-0423.html
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2018-02-14 14:52:56 +01:00
|
|
|
package = mkOption {
|
|
|
|
type = types.package;
|
|
|
|
description = "Prosody package to use";
|
|
|
|
default = pkgs.prosody;
|
2021-10-03 18:06:03 +02:00
|
|
|
defaultText = literalExpression "pkgs.prosody";
|
|
|
|
example = literalExpression ''
|
2018-02-14 14:52:56 +01:00
|
|
|
pkgs.prosody.override {
|
|
|
|
withExtraLibs = [ pkgs.luaPackages.lpty ];
|
|
|
|
withCommunityModules = [ "auth_external" ];
|
|
|
|
};
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2018-04-09 14:19:42 +02:00
|
|
|
dataDir = mkOption {
|
2019-08-08 22:48:27 +02:00
|
|
|
type = types.path;
|
2018-04-09 14:19:42 +02:00
|
|
|
description = "Directory where Prosody stores its data";
|
|
|
|
default = "/var/lib/prosody";
|
|
|
|
};
|
|
|
|
|
2020-04-20 20:27:53 +02:00
|
|
|
disco_items = mkOption {
|
|
|
|
type = types.listOf (types.submodule discoOpts);
|
|
|
|
default = [];
|
|
|
|
description = "List of discoverable items you want to advertise.";
|
|
|
|
};
|
|
|
|
|
2018-04-12 06:10:48 +02:00
|
|
|
user = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "prosody";
|
|
|
|
description = "User account under which prosody runs.";
|
|
|
|
};
|
|
|
|
|
|
|
|
group = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "prosody";
|
|
|
|
description = "Group account under which prosody runs.";
|
|
|
|
};
|
|
|
|
|
2014-09-02 17:08:56 +02:00
|
|
|
allowRegistration = mkOption {
|
2017-03-01 01:57:02 +01:00
|
|
|
type = types.bool;
|
2014-09-02 17:08:56 +02:00
|
|
|
default = false;
|
|
|
|
description = "Allow account creation";
|
|
|
|
};
|
|
|
|
|
2020-04-20 20:27:53 +02:00
|
|
|
# HTTP server-related options
|
|
|
|
httpPorts = mkOption {
|
|
|
|
type = types.listOf types.int;
|
|
|
|
description = "Listening HTTP ports list for this service.";
|
|
|
|
default = [ 5280 ];
|
|
|
|
};
|
|
|
|
|
|
|
|
httpInterfaces = mkOption {
|
|
|
|
type = types.listOf types.str;
|
|
|
|
default = [ "*" "::" ];
|
|
|
|
description = "Interfaces on which the HTTP server will listen on.";
|
|
|
|
};
|
|
|
|
|
|
|
|
httpsPorts = mkOption {
|
|
|
|
type = types.listOf types.int;
|
|
|
|
description = "Listening HTTPS ports list for this service.";
|
|
|
|
default = [ 5281 ];
|
|
|
|
};
|
|
|
|
|
|
|
|
httpsInterfaces = mkOption {
|
|
|
|
type = types.listOf types.str;
|
|
|
|
default = [ "*" "::" ];
|
|
|
|
description = "Interfaces on which the HTTPS server will listen on.";
|
|
|
|
};
|
|
|
|
|
2017-12-22 01:17:48 +01:00
|
|
|
c2sRequireEncryption = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = true;
|
|
|
|
description = ''
|
|
|
|
Force clients to use encrypted connections? This option will
|
|
|
|
prevent clients from authenticating unless they are using encryption.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
s2sRequireEncryption = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = true;
|
|
|
|
description = ''
|
|
|
|
Force servers to use encrypted connections? This option will
|
|
|
|
prevent servers from authenticating unless they are using encryption.
|
|
|
|
Note that this is different from authentication.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
s2sSecureAuth = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = false;
|
|
|
|
description = ''
|
|
|
|
Force certificate authentication for server-to-server connections?
|
|
|
|
This provides ideal security, but requires servers you communicate
|
|
|
|
with to support encryption AND present valid, trusted certificates.
|
|
|
|
For more information see https://prosody.im/doc/s2s#security
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
s2sInsecureDomains = mkOption {
|
|
|
|
type = types.listOf types.str;
|
|
|
|
default = [];
|
|
|
|
example = [ "insecure.example.com" ];
|
|
|
|
description = ''
|
|
|
|
Some servers have invalid or self-signed certificates. You can list
|
|
|
|
remote domains here that will not be required to authenticate using
|
|
|
|
certificates. They will be authenticated using DNS instead, even
|
|
|
|
when s2s_secure_auth is enabled.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
s2sSecureDomains = mkOption {
|
|
|
|
type = types.listOf types.str;
|
|
|
|
default = [];
|
|
|
|
example = [ "jabber.org" ];
|
|
|
|
description = ''
|
|
|
|
Even if you leave s2s_secure_auth disabled, you can still require valid
|
|
|
|
certificates for some domains by specifying a list here.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2014-09-02 17:08:56 +02:00
|
|
|
modules = moduleOpts;
|
|
|
|
|
|
|
|
extraModules = mkOption {
|
2017-03-01 01:57:02 +01:00
|
|
|
type = types.listOf types.str;
|
2014-09-02 17:08:56 +02:00
|
|
|
default = [];
|
2017-03-01 01:57:02 +01:00
|
|
|
description = "Enable custom modules";
|
2014-09-02 17:08:56 +02:00
|
|
|
};
|
|
|
|
|
2018-03-22 03:40:46 +01:00
|
|
|
extraPluginPaths = mkOption {
|
|
|
|
type = types.listOf types.path;
|
|
|
|
default = [];
|
|
|
|
description = "Addtional path in which to look find plugins/modules";
|
|
|
|
};
|
|
|
|
|
2020-04-20 20:27:53 +02:00
|
|
|
uploadHttp = mkOption {
|
|
|
|
description = ''
|
|
|
|
Configures the Prosody builtin HTTP server to handle user uploads.
|
|
|
|
'';
|
|
|
|
type = types.nullOr (types.submodule uploadHttpOpts);
|
|
|
|
default = null;
|
|
|
|
example = {
|
|
|
|
domain = "uploads.my-xmpp-example-host.org";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
muc = mkOption {
|
|
|
|
type = types.listOf (types.submodule mucOpts);
|
|
|
|
default = [ ];
|
|
|
|
example = [ {
|
|
|
|
domain = "conference.my-xmpp-example-host.org";
|
|
|
|
} ];
|
|
|
|
description = "Multi User Chat (MUC) configuration";
|
|
|
|
};
|
|
|
|
|
2014-09-02 17:08:56 +02:00
|
|
|
virtualHosts = mkOption {
|
|
|
|
|
|
|
|
description = "Define the virtual hosts";
|
|
|
|
|
2020-08-23 01:28:45 +02:00
|
|
|
type = with types; attrsOf (submodule vHostOpts);
|
2014-09-02 17:08:56 +02:00
|
|
|
|
|
|
|
example = {
|
|
|
|
myhost = {
|
|
|
|
domain = "my-xmpp-example-host.org";
|
2015-03-30 13:45:07 +02:00
|
|
|
enabled = true;
|
2014-09-02 17:08:56 +02:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
default = {
|
|
|
|
localhost = {
|
|
|
|
domain = "localhost";
|
2015-03-30 13:45:07 +02:00
|
|
|
enabled = true;
|
2014-09-02 17:08:56 +02:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
ssl = mkOption {
|
2017-03-01 01:57:02 +01:00
|
|
|
type = types.nullOr (types.submodule sslOpts);
|
2014-09-02 17:08:56 +02:00
|
|
|
default = null;
|
2017-03-01 01:57:02 +01:00
|
|
|
description = "Paths to SSL files";
|
2014-09-02 17:08:56 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
admins = mkOption {
|
2017-03-01 01:57:02 +01:00
|
|
|
type = types.listOf types.str;
|
2014-09-02 17:08:56 +02:00
|
|
|
default = [];
|
2017-03-01 01:57:02 +01:00
|
|
|
example = [ "admin1@example.com" "admin2@example.com" ];
|
|
|
|
description = "List of administrators of the current host";
|
2014-09-02 17:08:56 +02:00
|
|
|
};
|
|
|
|
|
2019-01-03 13:37:08 +01:00
|
|
|
authentication = mkOption {
|
|
|
|
type = types.enum [ "internal_plain" "internal_hashed" "cyrus" "anonymous" ];
|
|
|
|
default = "internal_hashed";
|
|
|
|
example = "internal_plain";
|
|
|
|
description = "Authentication mechanism used for logins.";
|
|
|
|
};
|
|
|
|
|
2014-09-02 17:08:56 +02:00
|
|
|
extraConfig = mkOption {
|
2016-10-23 19:33:41 +02:00
|
|
|
type = types.lines;
|
2017-03-01 01:57:02 +01:00
|
|
|
default = "";
|
2014-09-02 17:08:56 +02:00
|
|
|
description = "Additional prosody configuration";
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
###### implementation
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
|
2020-04-20 20:27:53 +02:00
|
|
|
assertions = let
|
|
|
|
genericErrMsg = ''
|
|
|
|
|
|
|
|
Having a server not XEP-0423-compliant might make your XMPP
|
|
|
|
experience terrible. See the NixOS manual for further
|
|
|
|
informations.
|
|
|
|
|
|
|
|
If you know what you're doing, you can disable this warning by
|
|
|
|
setting config.services.prosody.xmppComplianceSuite to false.
|
|
|
|
'';
|
|
|
|
errors = [
|
|
|
|
{ assertion = (builtins.length cfg.muc > 0) || !cfg.xmppComplianceSuite;
|
|
|
|
message = ''
|
|
|
|
You need to setup at least a MUC domain to comply with
|
|
|
|
XEP-0423.
|
|
|
|
'' + genericErrMsg;}
|
|
|
|
{ assertion = cfg.uploadHttp != null || !cfg.xmppComplianceSuite;
|
|
|
|
message = ''
|
|
|
|
You need to setup the uploadHttp module through
|
|
|
|
config.services.prosody.uploadHttp to comply with
|
|
|
|
XEP-0423.
|
|
|
|
'' + genericErrMsg;}
|
|
|
|
];
|
|
|
|
in errors;
|
|
|
|
|
2018-03-22 03:40:46 +01:00
|
|
|
environment.systemPackages = [ cfg.package ];
|
2014-09-02 17:08:56 +02:00
|
|
|
|
2020-04-20 20:27:53 +02:00
|
|
|
environment.etc."prosody/prosody.cfg.lua".text =
|
|
|
|
let
|
|
|
|
httpDiscoItems = if (cfg.uploadHttp != null)
|
|
|
|
then [{ url = cfg.uploadHttp.domain; description = "HTTP upload endpoint";}]
|
|
|
|
else [];
|
|
|
|
mucDiscoItems = builtins.foldl'
|
|
|
|
(acc: muc: [{ url = muc.domain; description = "${muc.domain} MUC endpoint";}] ++ acc)
|
|
|
|
[]
|
|
|
|
cfg.muc;
|
|
|
|
discoItems = cfg.disco_items ++ httpDiscoItems ++ mucDiscoItems;
|
|
|
|
in ''
|
2014-09-02 17:08:56 +02:00
|
|
|
|
2018-04-13 11:38:52 +02:00
|
|
|
pidfile = "/run/prosody/prosody.pid"
|
2014-09-02 17:08:56 +02:00
|
|
|
|
|
|
|
log = "*syslog"
|
|
|
|
|
2018-04-09 14:19:42 +02:00
|
|
|
data_path = "${cfg.dataDir}"
|
2018-03-22 03:40:46 +01:00
|
|
|
plugin_paths = {
|
|
|
|
${lib.concatStringsSep ", " (map (n: "\"${n}\"") cfg.extraPluginPaths) }
|
|
|
|
}
|
2014-09-02 17:08:56 +02:00
|
|
|
|
|
|
|
${ optionalString (cfg.ssl != null) (createSSLOptsStr cfg.ssl) }
|
|
|
|
|
2017-12-22 01:17:48 +01:00
|
|
|
admins = ${toLua cfg.admins}
|
|
|
|
|
|
|
|
-- we already build with libevent, so we can just enable it for a more performant server
|
|
|
|
use_libevent = true
|
2014-09-02 17:08:56 +02:00
|
|
|
|
|
|
|
modules_enabled = {
|
|
|
|
|
2019-09-17 02:20:05 +02:00
|
|
|
${ lib.concatStringsSep "\n " (lib.mapAttrsToList
|
2017-12-22 01:17:48 +01:00
|
|
|
(name: val: optionalString val "${toLua name};")
|
2014-09-02 17:08:56 +02:00
|
|
|
cfg.modules) }
|
2018-03-22 03:40:46 +01:00
|
|
|
${ lib.concatStringsSep "\n" (map (x: "${toLua x};") cfg.package.communityModules)}
|
2017-12-22 01:17:48 +01:00
|
|
|
${ lib.concatStringsSep "\n" (map (x: "${toLua x};") cfg.extraModules)}
|
|
|
|
};
|
2014-09-02 17:08:56 +02:00
|
|
|
|
2020-04-20 20:27:53 +02:00
|
|
|
disco_items = {
|
2020-08-07 15:43:58 +02:00
|
|
|
${ lib.concatStringsSep "\n" (builtins.map (x: ''{ "${x.url}", "${x.description}"};'') discoItems)}
|
2020-04-20 20:27:53 +02:00
|
|
|
};
|
|
|
|
|
2017-12-22 01:17:48 +01:00
|
|
|
allow_registration = ${toLua cfg.allowRegistration}
|
|
|
|
|
|
|
|
c2s_require_encryption = ${toLua cfg.c2sRequireEncryption}
|
|
|
|
|
|
|
|
s2s_require_encryption = ${toLua cfg.s2sRequireEncryption}
|
|
|
|
|
|
|
|
s2s_secure_auth = ${toLua cfg.s2sSecureAuth}
|
|
|
|
|
|
|
|
s2s_insecure_domains = ${toLua cfg.s2sInsecureDomains}
|
|
|
|
|
|
|
|
s2s_secure_domains = ${toLua cfg.s2sSecureDomains}
|
2014-09-02 17:08:56 +02:00
|
|
|
|
2019-01-03 13:37:08 +01:00
|
|
|
authentication = ${toLua cfg.authentication}
|
2014-09-02 17:08:56 +02:00
|
|
|
|
2020-04-20 20:27:53 +02:00
|
|
|
http_interfaces = ${toLua cfg.httpInterfaces}
|
|
|
|
|
|
|
|
https_interfaces = ${toLua cfg.httpsInterfaces}
|
|
|
|
|
|
|
|
http_ports = ${toLua cfg.httpPorts}
|
|
|
|
|
|
|
|
https_ports = ${toLua cfg.httpsPorts}
|
|
|
|
|
2020-05-04 00:10:33 +02:00
|
|
|
${ cfg.extraConfig }
|
|
|
|
|
2020-04-20 20:27:53 +02:00
|
|
|
${lib.concatMapStrings (muc: ''
|
|
|
|
Component ${toLua muc.domain} "muc"
|
|
|
|
modules_enabled = { "muc_mam"; ${optionalString muc.vcard_muc ''"vcard_muc";'' } }
|
|
|
|
name = ${toLua muc.name}
|
|
|
|
restrict_room_creation = ${toLua muc.restrictRoomCreation}
|
|
|
|
max_history_messages = ${toLua muc.maxHistoryMessages}
|
|
|
|
muc_room_locking = ${toLua muc.roomLocking}
|
|
|
|
muc_room_lock_timeout = ${toLua muc.roomLockTimeout}
|
|
|
|
muc_tombstones = ${toLua muc.tombstones}
|
|
|
|
muc_tombstone_expiry = ${toLua muc.tombstoneExpiry}
|
|
|
|
muc_room_default_public = ${toLua muc.roomDefaultPublic}
|
|
|
|
muc_room_default_members_only = ${toLua muc.roomDefaultMembersOnly}
|
|
|
|
muc_room_default_moderated = ${toLua muc.roomDefaultModerated}
|
|
|
|
muc_room_default_public_jids = ${toLua muc.roomDefaultPublicJids}
|
|
|
|
muc_room_default_change_subject = ${toLua muc.roomDefaultChangeSubject}
|
|
|
|
muc_room_default_history_length = ${toLua muc.roomDefaultHistoryLength}
|
|
|
|
muc_room_default_language = ${toLua muc.roomDefaultLanguage}
|
2020-05-04 00:10:33 +02:00
|
|
|
${ muc.extraConfig }
|
|
|
|
'') cfg.muc}
|
2020-04-20 20:27:53 +02:00
|
|
|
|
|
|
|
${ lib.optionalString (cfg.uploadHttp != null) ''
|
|
|
|
Component ${toLua cfg.uploadHttp.domain} "http_upload"
|
|
|
|
http_upload_file_size_limit = ${cfg.uploadHttp.uploadFileSizeLimit}
|
|
|
|
http_upload_expire_after = ${cfg.uploadHttp.uploadExpireAfter}
|
|
|
|
${lib.optionalString (cfg.uploadHttp.userQuota != null) "http_upload_quota = ${toLua cfg.uploadHttp.userQuota}"}
|
|
|
|
http_upload_path = ${toLua cfg.uploadHttp.httpUploadPath}
|
|
|
|
''}
|
|
|
|
|
2014-09-02 17:08:56 +02:00
|
|
|
${ lib.concatStringsSep "\n" (lib.mapAttrsToList (n: v: ''
|
|
|
|
VirtualHost "${v.domain}"
|
2017-04-11 18:08:51 +02:00
|
|
|
enabled = ${boolToString v.enabled};
|
2014-09-02 17:08:56 +02:00
|
|
|
${ optionalString (v.ssl != null) (createSSLOptsStr v.ssl) }
|
|
|
|
${ v.extraConfig }
|
|
|
|
'') cfg.virtualHosts) }
|
|
|
|
'';
|
|
|
|
|
2018-06-30 01:58:35 +02:00
|
|
|
users.users.prosody = mkIf (cfg.user == "prosody") {
|
2014-09-02 17:08:56 +02:00
|
|
|
uid = config.ids.uids.prosody;
|
|
|
|
description = "Prosody user";
|
|
|
|
createHome = true;
|
2018-04-12 06:10:48 +02:00
|
|
|
inherit (cfg) group;
|
2018-04-09 14:19:42 +02:00
|
|
|
home = "${cfg.dataDir}";
|
2014-09-02 17:08:56 +02:00
|
|
|
};
|
|
|
|
|
2018-06-30 01:58:35 +02:00
|
|
|
users.groups.prosody = mkIf (cfg.group == "prosody") {
|
2014-09-02 17:08:56 +02:00
|
|
|
gid = config.ids.gids.prosody;
|
|
|
|
};
|
|
|
|
|
|
|
|
systemd.services.prosody = {
|
|
|
|
description = "Prosody XMPP server";
|
2017-02-23 16:05:06 +01:00
|
|
|
after = [ "network-online.target" ];
|
|
|
|
wants = [ "network-online.target" ];
|
2014-09-02 17:08:56 +02:00
|
|
|
wantedBy = [ "multi-user.target" ];
|
2017-03-01 01:57:02 +01:00
|
|
|
restartTriggers = [ config.environment.etc."prosody/prosody.cfg.lua".source ];
|
2014-09-02 17:08:56 +02:00
|
|
|
serviceConfig = {
|
2018-04-12 06:10:48 +02:00
|
|
|
User = cfg.user;
|
|
|
|
Group = cfg.group;
|
2017-03-01 01:57:02 +01:00
|
|
|
Type = "forking";
|
2018-04-13 11:38:52 +02:00
|
|
|
RuntimeDirectory = [ "prosody" ];
|
|
|
|
PIDFile = "/run/prosody/prosody.pid";
|
2018-02-14 14:52:56 +01:00
|
|
|
ExecStart = "${cfg.package}/bin/prosodyctl start";
|
2019-01-26 03:08:23 +01:00
|
|
|
ExecReload = "${pkgs.coreutils}/bin/kill -HUP $MAINPID";
|
2020-04-26 15:18:49 +02:00
|
|
|
|
|
|
|
MemoryDenyWriteExecute = true;
|
|
|
|
PrivateDevices = true;
|
|
|
|
PrivateMounts = true;
|
|
|
|
PrivateTmp = true;
|
|
|
|
ProtectControlGroups = true;
|
|
|
|
ProtectHome = true;
|
|
|
|
ProtectHostname = true;
|
|
|
|
ProtectKernelModules = true;
|
|
|
|
ProtectKernelTunables = true;
|
|
|
|
RestrictNamespaces = true;
|
|
|
|
RestrictRealtime = true;
|
|
|
|
RestrictSUIDSGID = true;
|
2014-09-02 17:08:56 +02:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
2020-05-01 19:11:24 +02:00
|
|
|
meta.doc = ./prosody.xml;
|
2014-09-02 17:08:56 +02:00
|
|
|
}
|