nixpkgs/pkgs/servers/xmpp/prosody/default.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

88 lines
2.5 KiB
Nix
Raw Normal View History

nixos/prosody: make defaults comply with XEP-0423 Setting up a XMPP chat server is a pretty deep rabbit whole to jump in when you're not familiar with this whole universe. Your experience with this environment will greatly depends on whether or not your server implements the right set of XEPs. To tackle this problem, the XMPP community came with the idea of creating a meta-XEP in charge of listing the desirable XEPs to comply with. This meta-XMP is issued every year under an new XEP number. The 2020 one being XEP-0423[1]. This prosody nixos module refactoring makes complying with XEP-0423 easier. All the necessary extensions are enabled by default. For some extensions (MUC and HTTP_UPLOAD), we need some input from the user and cannot provide a sensible default nixpkgs-wide. For those, we guide the user using a couple of assertions explaining the remaining manual steps to perform. We took advantage of this substential refactoring to refresh the associated nixos test. Changelog: - Update the prosody package to provide the necessary community modules in order to comply with XEP-0423. This is a tradeoff, as depending on their configuration, the user might end up not using them and wasting some disk space. That being said, adding those will allow the XEP-0423 users, which I expect to be the majority of users, to leverage a bit more the binary cache. - Add a muc submodule populated with the prosody muc defaults. - Add a http_upload submodule in charge of setting up a basic http server handling the user uploads. This submodule is in is spinning up an HTTP(s) server in charge of receiving and serving the user's attachments. - Advertise both the MUCs and the http_upload endpoints using mod disco. - Use the slixmpp library in place of the now defunct sleekxmpp for the prosody NixOS test. - Update the nixos test to setup and test the MUC and http upload features. - Add a couple of assertions triggered if the setup is not xep-0423 compliant. [1] https://xmpp.org/extensions/xep-0423.html
2020-04-20 20:27:53 +02:00
{ stdenv, fetchurl, lib, libidn, openssl, makeWrapper, fetchhg
, icu
2021-09-12 00:00:26 +02:00
, lua
2020-05-24 21:05:42 +02:00
, nixosTests
2021-09-12 00:00:26 +02:00
, withLibevent ? true
, withDBI ? true
# use withExtraLibs to add additional dependencies of community modules
, withExtraLibs ? [ ]
, withExtraLuaPackages ? _: [ ]
2018-03-22 03:40:46 +01:00
, withOnlyInstalledCommunityModules ? [ ]
, withCommunityModules ? [ ] }:
2015-02-19 12:09:38 +01:00
2021-01-15 08:07:56 +01:00
with lib;
2021-09-12 00:00:26 +02:00
let
luaEnv = lua.withPackages(p: with p; [
luasocket luasec luaexpat luafilesystem luabitop luadbi-sqlite3 luaunbound
2021-09-12 00:00:26 +02:00
]
++ lib.optional withLibevent p.luaevent
++ lib.optional withDBI p.luadbi
++ withExtraLuaPackages p
2021-09-12 00:00:26 +02:00
);
in
stdenv.mkDerivation rec {
2022-08-05 15:57:32 +02:00
version = "0.12.1"; # also update communityModules
pname = "prosody";
nixos/prosody: make defaults comply with XEP-0423 Setting up a XMPP chat server is a pretty deep rabbit whole to jump in when you're not familiar with this whole universe. Your experience with this environment will greatly depends on whether or not your server implements the right set of XEPs. To tackle this problem, the XMPP community came with the idea of creating a meta-XEP in charge of listing the desirable XEPs to comply with. This meta-XMP is issued every year under an new XEP number. The 2020 one being XEP-0423[1]. This prosody nixos module refactoring makes complying with XEP-0423 easier. All the necessary extensions are enabled by default. For some extensions (MUC and HTTP_UPLOAD), we need some input from the user and cannot provide a sensible default nixpkgs-wide. For those, we guide the user using a couple of assertions explaining the remaining manual steps to perform. We took advantage of this substential refactoring to refresh the associated nixos test. Changelog: - Update the prosody package to provide the necessary community modules in order to comply with XEP-0423. This is a tradeoff, as depending on their configuration, the user might end up not using them and wasting some disk space. That being said, adding those will allow the XEP-0423 users, which I expect to be the majority of users, to leverage a bit more the binary cache. - Add a muc submodule populated with the prosody muc defaults. - Add a http_upload submodule in charge of setting up a basic http server handling the user uploads. This submodule is in is spinning up an HTTP(s) server in charge of receiving and serving the user's attachments. - Advertise both the MUCs and the http_upload endpoints using mod disco. - Use the slixmpp library in place of the now defunct sleekxmpp for the prosody NixOS test. - Update the nixos test to setup and test the MUC and http upload features. - Add a couple of assertions triggered if the setup is not xep-0423 compliant. [1] https://xmpp.org/extensions/xep-0423.html
2020-04-20 20:27:53 +02:00
# The following community modules are necessary for the nixos module
# prosody module to comply with XEP-0423 and provide a working
# default setup.
nixosModuleDeps = [
"cloud_notify"
"vcard_muc"
"http_upload"
];
src = fetchurl {
url = "https://prosody.im/downloads/source/${pname}-${version}.tar.gz";
2022-08-05 15:57:32 +02:00
sha256 = "sha256-p+y75B8BpCUYBVk6xtFdvGy3XZx6h2x2tFbPdP9LkOU=";
};
# A note to all those merging automated updates: Please also update this
# attribute as some modules might not be compatible with a newer prosody
# version.
2014-10-15 03:57:00 +02:00
communityModules = fetchhg {
url = "https://hg.prosody.im/prosody-modules";
2022-08-05 15:57:32 +02:00
rev = "cce12a660b98";
sha256 = "sha256-dFWS1EFd2wtFnnuU4xKPnBisIdKkgMAvBtsfAEbdLjE=";
2014-10-15 03:57:00 +02:00
};
2021-09-12 00:00:26 +02:00
nativeBuildInputs = [ makeWrapper ];
luaPackages: Replace all rockspec packages with generated ones luaPackages replaced by generated ones: - bit32 - compat53 - cqueues - luacyrussasl -> cyrussasl (luarocks name) - luaexpat - luadbi -> luadbi front-end module + separate backend modules luadbi-{mysql,postgresql,sqlite3} - luafilesystem - luaossl - luasec - luasocket - luastdlib -> stdlib (luarocks name) - lrexlib -> lrexlib-pcre (we already have lrexlib-gnu and lrexlib-posix, lrexlib-pcre however appears to be the variant used in mudlet, which is the only current dep in nixpkgs) - luasqlite -> luasql-sqlite3 (luarocks name) - lfs -> luafilesytem (we literally had two manually written luafilesystem expressions, under different names) Changes and additions to overrides to generated luarocks packgaes, including: - busted: Install bash completions along with the zsh ones - cqueues: - Perform minor surgery on the rockspec to allow using a single rockspec to build for all supported Lua versions - Add a patch by @vcunat to work around a build issue - luuid: Wrote a tiny patch to allow for Lua 5.1/Luajit compatibility - General changes: - Sorted the packages - Attempted to make the formatting consistent - Preferenced `.override` instead of `.overrideAttrs` wherever possible Minor changes to other packages to adjust for the Lua package changes: - luakit expression simplified - prosody expression simplified; but users will now need to specify the luadbi backend module they intend to use in withExtraLibs - knot-resolver inputs correctd - mudlet inputs corrected (although this package was and should still be broken)
2019-06-13 13:01:10 +02:00
buildInputs = [
luaEnv libidn openssl icu
luaPackages: Replace all rockspec packages with generated ones luaPackages replaced by generated ones: - bit32 - compat53 - cqueues - luacyrussasl -> cyrussasl (luarocks name) - luaexpat - luadbi -> luadbi front-end module + separate backend modules luadbi-{mysql,postgresql,sqlite3} - luafilesystem - luaossl - luasec - luasocket - luastdlib -> stdlib (luarocks name) - lrexlib -> lrexlib-pcre (we already have lrexlib-gnu and lrexlib-posix, lrexlib-pcre however appears to be the variant used in mudlet, which is the only current dep in nixpkgs) - luasqlite -> luasql-sqlite3 (luarocks name) - lfs -> luafilesytem (we literally had two manually written luafilesystem expressions, under different names) Changes and additions to overrides to generated luarocks packgaes, including: - busted: Install bash completions along with the zsh ones - cqueues: - Perform minor surgery on the rockspec to allow using a single rockspec to build for all supported Lua versions - Add a patch by @vcunat to work around a build issue - luuid: Wrote a tiny patch to allow for Lua 5.1/Luajit compatibility - General changes: - Sorted the packages - Attempted to make the formatting consistent - Preferenced `.override` instead of `.overrideAttrs` wherever possible Minor changes to other packages to adjust for the Lua package changes: - luakit expression simplified - prosody expression simplified; but users will now need to specify the luadbi backend module they intend to use in withExtraLibs - knot-resolver inputs correctd - mudlet inputs corrected (although this package was and should still be broken)
2019-06-13 13:01:10 +02:00
]
++ withExtraLibs;
configureFlags = [
"--ostype=linux"
2021-09-12 00:00:26 +02:00
"--with-lua-include=${luaEnv}/include"
"--with-lua=${luaEnv}"
];
2020-11-01 01:56:10 +01:00
postBuild = ''
make -C tools/migration
'';
2021-09-12 00:00:26 +02:00
# the wrapping should go away once lua hook is fixed
postInstall = ''
${concatMapStringsSep "\n" (module: ''
cp -r $communityModules/mod_${module} $out/lib/prosody/modules/
nixos/prosody: make defaults comply with XEP-0423 Setting up a XMPP chat server is a pretty deep rabbit whole to jump in when you're not familiar with this whole universe. Your experience with this environment will greatly depends on whether or not your server implements the right set of XEPs. To tackle this problem, the XMPP community came with the idea of creating a meta-XEP in charge of listing the desirable XEPs to comply with. This meta-XMP is issued every year under an new XEP number. The 2020 one being XEP-0423[1]. This prosody nixos module refactoring makes complying with XEP-0423 easier. All the necessary extensions are enabled by default. For some extensions (MUC and HTTP_UPLOAD), we need some input from the user and cannot provide a sensible default nixpkgs-wide. For those, we guide the user using a couple of assertions explaining the remaining manual steps to perform. We took advantage of this substential refactoring to refresh the associated nixos test. Changelog: - Update the prosody package to provide the necessary community modules in order to comply with XEP-0423. This is a tradeoff, as depending on their configuration, the user might end up not using them and wasting some disk space. That being said, adding those will allow the XEP-0423 users, which I expect to be the majority of users, to leverage a bit more the binary cache. - Add a muc submodule populated with the prosody muc defaults. - Add a http_upload submodule in charge of setting up a basic http server handling the user uploads. This submodule is in is spinning up an HTTP(s) server in charge of receiving and serving the user's attachments. - Advertise both the MUCs and the http_upload endpoints using mod disco. - Use the slixmpp library in place of the now defunct sleekxmpp for the prosody NixOS test. - Update the nixos test to setup and test the MUC and http upload features. - Add a couple of assertions triggered if the setup is not xep-0423 compliant. [1] https://xmpp.org/extensions/xep-0423.html
2020-04-20 20:27:53 +02:00
'') (lib.lists.unique(nixosModuleDeps ++ withCommunityModules ++ withOnlyInstalledCommunityModules))}
wrapProgram $out/bin/prosodyctl \
--add-flags '--config "/etc/prosody/prosody.cfg.lua"'
2020-11-01 01:56:10 +01:00
make -C tools/migration install
'';
2020-05-24 21:05:42 +02:00
passthru = {
communityModules = withCommunityModules;
tests = { inherit (nixosTests) prosody prosody-mysql; };
2020-05-24 21:05:42 +02:00
};
2018-03-22 03:40:46 +01:00
meta = {
description = "Open-source XMPP application server written in Lua";
2015-02-19 12:09:38 +01:00
license = licenses.mit;
homepage = "https://prosody.im";
2015-02-19 12:09:38 +01:00
platforms = platforms.linux;
maintainers = with maintainers; [ globin ];
};
}