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

121 lines
3.3 KiB
Nix
Raw Normal View History

{ stdenv, writeScriptBin, makeWrapper, lib, fetchurl, git, cacert, libpng, libjpeg, libwebp
2018-02-25 09:17:51 -08:00
, erlang, openssl, expat, libyaml, bash, gnused, gnugrep, coreutils, utillinux, procps, gd
, flock
2015-09-11 13:39:21 -07:00
, withMysql ? false
, withPgsql ? false
, withSqlite ? false, sqlite
, withPam ? false, pam
, withZlib ? true, zlib
, withRiak ? false
, withElixir ? false, elixir
, withIconv ? true
, withTools ? false
, withRedis ? false
}:
2015-09-11 13:39:21 -07:00
let
fakegit = writeScriptBin "git" ''
2016-02-10 15:36:09 -08:00
#! ${stdenv.shell} -e
if [ "$1" = "describe" ]; then
[ -r .rev ] && cat .rev || true
fi
2015-09-11 13:39:21 -07:00
'';
2016-04-29 10:56:02 -07:00
ctlpath = lib.makeBinPath [ bash gnused gnugrep coreutils utillinux procps ];
2015-09-11 13:39:21 -07:00
in stdenv.mkDerivation rec {
version = "18.06";
2013-11-01 17:46:30 -07:00
name = "ejabberd-${version}";
2015-09-11 13:39:21 -07:00
src = fetchurl {
2018-04-30 20:03:23 -07:00
url = "https://www.process-one.net/downloads/ejabberd/${version}/${name}.tgz";
sha256 = "1c4h6qrckihm8v4vm52h31j5dxg7247vk374rwz41idfb25vx7dc";
};
2015-09-11 13:39:21 -07:00
nativeBuildInputs = [ fakegit ];
buildInputs = [ erlang openssl expat libyaml gd makeWrapper ]
2015-09-11 13:39:21 -07:00
++ lib.optional withSqlite sqlite
++ lib.optional withPam pam
++ lib.optional withZlib zlib
++ lib.optional withElixir elixir
;
# Apparently needed for Elixir
LANG = "en_US.UTF-8";
2016-04-29 10:56:02 -07:00
deps = stdenv.mkDerivation {
name = "ejabberd-deps-${version}";
inherit src;
configureFlags = [ "--enable-all" "--with-sqlite3=${sqlite.dev}" ];
2016-04-29 10:56:02 -07:00
nativeBuildInputs = [ git erlang openssl expat libyaml sqlite pam zlib elixir ];
2016-04-29 10:56:02 -07:00
GIT_SSL_CAINFO = "${cacert}/etc/ssl/certs/ca-bundle.crt";
makeFlags = [ "deps" ];
phases = [ "unpackPhase" "configurePhase" "buildPhase" "installPhase" ];
2016-04-29 10:56:02 -07:00
installPhase = ''
for i in deps/*; do
( cd $i
git reset --hard
git clean -ffdx
2016-04-29 10:56:02 -07:00
git describe --always --tags > .rev
rm -rf .git
)
done
2016-04-29 17:48:47 -07:00
rm deps/.got
2016-04-29 10:56:02 -07:00
cp -r deps $out
'';
outputHashMode = "recursive";
outputHashAlgo = "sha256";
outputHash = "1bk3yd10cq6vlgmh2qawl82m29yi5zcbsdlz17xyy76sg2ka622a";
2016-04-29 10:56:02 -07:00
};
2015-09-11 13:39:21 -07:00
configureFlags =
2016-02-10 15:36:09 -08:00
[ (lib.enableFeature withMysql "mysql")
2015-09-11 13:39:21 -07:00
(lib.enableFeature withPgsql "pgsql")
(lib.enableFeature withSqlite "sqlite")
(lib.enableFeature withPam "pam")
(lib.enableFeature withZlib "zlib")
(lib.enableFeature withRiak "riak")
(lib.enableFeature withElixir "elixir")
(lib.enableFeature withIconv "iconv")
(lib.enableFeature withTools "tools")
(lib.enableFeature withRedis "redis")
] ++ lib.optional withSqlite "--with-sqlite3=${sqlite.dev}";
2015-09-11 13:39:21 -07:00
enableParallelBuilding = true;
preBuild = ''
2016-04-29 10:56:02 -07:00
cp -r $deps deps
chmod -R +w deps
2016-07-23 02:23:25 -07:00
patchShebangs deps
'';
2015-09-11 13:39:21 -07:00
postInstall = ''
sed -i \
-e '2iexport PATH=${ctlpath}:$PATH' \
-e 's,\(^ *FLOCK=\).*,\1${flock}/bin/flock,' \
2015-09-11 13:39:21 -07:00
-e 's,\(^ *JOT=\).*,\1,' \
-e 's,\(^ *CONNLOCKDIR=\).*,\1/var/lock/ejabberdctl,' \
$out/sbin/ejabberdctl
wrapProgram $out/lib/eimp-*/priv/bin/eimp --prefix LD_LIBRARY_PATH : "${stdenv.lib.makeLibraryPath [ libpng libjpeg libwebp ]}"
2013-11-01 17:46:30 -07:00
'';
2018-02-25 09:17:51 -08:00
meta = with stdenv.lib; {
description = "Open-source XMPP application server written in Erlang";
2018-02-25 09:17:51 -08:00
license = licenses.gpl2;
2018-04-30 20:03:23 -07:00
homepage = https://www.ejabberd.im;
2018-02-25 09:17:51 -08:00
platforms = platforms.linux;
maintainers = with maintainers; [ sander abbradar ];
2016-04-29 10:56:02 -07:00
broken = withElixir;
};
}