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

295 lines
8.8 KiB
Nix
Raw Normal View History

2015-09-11 13:39:21 -07:00
{ stdenv, writeScriptBin, lib, fetchurl, fetchFromGitHub
, erlang, openssl, expat, libyaml, bash, gnused, gnugrep, coreutils, utillinux, procps
, 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
ctlpath = lib.makeSearchPath "bin" [ bash gnused gnugrep coreutils utillinux procps ];
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-02-10 15:36:09 -08:00
# These can be extracted from `rebar.config`
2015-09-11 13:39:21 -07:00
# Some dependencies are from another packages. Try commenting them out; then during build
# you'll get necessary revision information.
ejdeps = {
2016-03-03 06:00:54 -08:00
lager = fetchFromGitHub {
owner = "basho";
repo = "lager";
rev = "3.0.2";
sha256 = "04l40dlqpl2y6ddpbpknmnjf537bjvrmg8r0jnmw1h60dgyb2ydk";
};
# dependency of lager
goldrush = fetchFromGitHub {
owner = "DeadZen";
repo = "goldrush";
rev = "0.1.7";
sha256 = "1104j8v86hdavxf08yjyjkpi5vf95rfvsywdx29c69x3z33i4z3m";
};
p1_utils = fetchFromGitHub {
owner = "processone";
repo = "p1_utils";
rev = "1.0.3";
sha256 = "0bw163wx0ji2sz7yb3nzvm1mnnljsdji606xzk33za8c4sgrb4nj";
};
2016-02-10 15:36:09 -08:00
cache_tab = fetchFromGitHub {
2015-09-11 13:39:21 -07:00
owner = "processone";
repo = "cache_tab";
2016-03-03 06:00:54 -08:00
rev = "1.0.2";
sha256 = "1krgn6y95jgc8pc0vkj36p0wcazsb8b6h1x4f0r1936jff2vqk33";
2015-09-11 13:39:21 -07:00
};
2016-03-03 06:00:54 -08:00
fast_tls = fetchFromGitHub {
2015-09-11 13:39:21 -07:00
owner = "processone";
2016-03-03 06:00:54 -08:00
repo = "fast_tls";
rev = "1.0.1";
sha256 = "08lh6935k590hix3z69kjjd75w68vmmjcx7gi4zh8j7li4v9k9l2";
2015-09-11 13:39:21 -07:00
};
2016-03-03 06:00:54 -08:00
stringprep = fetchFromGitHub {
2015-09-11 13:39:21 -07:00
owner = "processone";
repo = "stringprep";
2016-03-03 06:00:54 -08:00
rev = "1.0.2";
sha256 = "1wrisajyll45wf6cz1rb2q70sz83i6nfnfiijsbzhy0xk51436sa";
2015-09-11 13:39:21 -07:00
};
2016-03-03 06:00:54 -08:00
fast_xml = fetchFromGitHub {
2015-09-11 13:39:21 -07:00
owner = "processone";
2016-03-03 06:00:54 -08:00
repo = "fast_xml";
rev = "1.1.3";
sha256 = "1a2k21fqz8rp4laz7wn0hsxy58i1gdwc3qhw3k2kar8lgw4m3wqp";
2015-09-11 13:39:21 -07:00
};
2016-03-03 06:00:54 -08:00
stun = fetchFromGitHub {
2015-09-11 13:39:21 -07:00
owner = "processone";
repo = "stun";
2016-03-03 06:00:54 -08:00
rev = "1.0.1";
sha256 = "0bq0qkc7h3nhqxa6ff2nf6bi4kiax4208716hxfz6l1vxrh7f3p2";
2015-09-11 13:39:21 -07:00
};
2016-03-03 06:00:54 -08:00
esip = fetchFromGitHub {
2015-09-11 13:39:21 -07:00
owner = "processone";
2016-03-03 06:00:54 -08:00
repo = "esip";
rev = "1.0.2";
sha256 = "0ibvb85wkqw81y154bagp0kgf1jmdscmfq8yk73j1k986dmiqfn2";
2015-09-11 13:39:21 -07:00
};
2016-03-03 06:00:54 -08:00
fast_yaml = fetchFromGitHub {
2015-09-11 13:39:21 -07:00
owner = "processone";
2016-03-03 06:00:54 -08:00
repo = "fast_yaml";
2016-02-10 15:36:09 -08:00
rev = "1.0.2";
2016-03-03 06:00:54 -08:00
sha256 = "019imn255bkkvilg4nrcidl8w6dn2jrb2nyrs2nixsgcbmvkdl5k";
2015-09-11 13:39:21 -07:00
};
jiffy = fetchFromGitHub {
owner = "davisp";
repo = "jiffy";
2016-03-03 06:00:54 -08:00
rev = "0.14.7";
sha256 = "1w55vwz4a94v0aajm3lg6nlhpw2w0zdddiw36f2n4sfhbqn0v0jr";
2015-09-11 13:39:21 -07:00
};
2016-03-03 06:00:54 -08:00
p1_oauth2 = fetchFromGitHub {
owner = "processone";
repo = "p1_oauth2";
rev = "0.6.1";
sha256 = "1wvmi3fj05hlbi3sbqpakznq70n76a7nbvbrjhr8k79bmvsh6lyl";
};
p1_xmlrpc = fetchFromGitHub {
owner = "processone";
repo = "p1_xmlrpc";
rev = "1.15.1";
sha256 = "12pfvb3k9alzg7qbph3bc1sw7wk86psm3jrdrfclq90zlpwqa0w3";
2015-09-11 13:39:21 -07:00
};
2016-03-03 06:00:54 -08:00
luerl = fetchFromGitHub {
owner = "rvirding";
repo = "luerl";
rev = "9524d0309a88b7c62ae93da0b632b185de3ba9db";
sha256 = "15yplmv2xybnz3nby940752jw672vj99l1j61rrfy686hgrfnc42";
2015-09-11 13:39:21 -07:00
};
p1_mysql = fetchFromGitHub {
owner = "processone";
2016-03-03 06:00:54 -08:00
repo = "p1_mysql";
rev = "1.0.1";
sha256 = "17122xhc420kqfsv4c4g0jcllpdbhg84wdlwd3227w4q729jg6bk";
2015-09-11 13:39:21 -07:00
};
p1_pgsql = fetchFromGitHub {
owner = "processone";
2016-03-03 06:00:54 -08:00
repo = "p1_pgsql";
rev = "1.0.1";
sha256 = "1ca0hhxyfmwjp49zjga1fdhrbaqnxdpmcvs2i6nz6jmapik788nr";
2015-09-11 13:39:21 -07:00
};
sqlite3 = fetchFromGitHub {
2016-03-03 06:00:54 -08:00
owner = "processone";
2015-09-11 13:39:21 -07:00
repo = "erlang-sqlite3";
2016-03-03 06:00:54 -08:00
rev = "1.1.5";
sha256 = "17n4clysg540nx9g8k8mi9l7vkz8wigycgxmzzn0wmgxdf6mhxlb";
2015-09-11 13:39:21 -07:00
};
p1_pam = fetchFromGitHub {
owner = "processone";
repo = "epam";
2016-02-10 15:36:09 -08:00
rev = "1.0.0";
sha256 = "0dlbmfwndhyg855vnhwyccxcjqzf2wcgc7522mjb9q38cva50rpr";
2015-09-11 13:39:21 -07:00
};
2016-03-03 06:00:54 -08:00
ezlib = fetchFromGitHub {
2015-09-11 13:39:21 -07:00
owner = "processone";
2016-03-03 06:00:54 -08:00
repo = "ezlib";
rev = "1.0.1";
sha256 = "1asp7s2q72iql870igc827dvi9iqyd6lhs0q3jbjj2w7xfz4x4kk";
2016-02-10 15:36:09 -08:00
};
hamcrest = fetchFromGitHub {
owner = "hyperthunk";
repo = "hamcrest-erlang";
rev = "908a24fda4a46776a5135db60ca071e3d783f9f6";
sha256 = "0irxidwrb37m0xwls6q9nn2zfs3pyxrgbnjgrhnh7gm35ib51hkj";
2015-09-11 13:39:21 -07:00
};
riakc = fetchFromGitHub {
owner = "basho";
repo = "riak-erlang-client";
2016-02-10 15:36:09 -08:00
rev = "527722d12d0433b837cdb92a60900c2cb5df8942";
sha256 = "13rkwibsjsl2gdysvf11r1hqfrf89hjgpa0x0hz2910f2ryqll3y";
2015-09-11 13:39:21 -07:00
};
# dependency of riakc
riak_pb = fetchFromGitHub {
owner = "basho";
repo = "riak_pb";
2016-02-10 15:36:09 -08:00
rev = "2.1.0.7";
sha256 = "1p0qmjq069f7j1m29dv36ayvz8m0pcm94ccsnv5blykfg2c5ja0c";
2015-09-11 13:39:21 -07:00
};
# dependency of riak_pb
protobuffs = fetchFromGitHub {
owner = "basho";
repo = "erlang_protobuffs";
2016-02-10 15:36:09 -08:00
rev = "0.8.2";
sha256 = "0w4jmsnc9x2ykqh1q6b12pl8a9973dxdhqk3y0ph17n83q5xz3h7";
2015-09-11 13:39:21 -07:00
};
elixir = fetchFromGitHub {
owner = "elixir-lang";
repo = "elixir";
2016-02-10 15:36:09 -08:00
rev = "v1.1.0";
sha256 = "0r5673x2qdvfbwmvyvj8ddvzgxnkl3cv9jsf1yzsxgdifjbrzwx7";
2015-09-11 13:39:21 -07:00
};
2016-03-03 06:00:54 -08:00
rebar_elixir_plugin = fetchFromGitHub {
2015-09-11 13:39:21 -07:00
owner = "processone";
2016-03-03 06:00:54 -08:00
repo = "rebar_elixir_plugin";
rev = "0.1.0";
sha256 = "0x04ff53mxwd9va8nl4m70dbamp6p4dpxs646c168iqpnpadk3sk";
2015-09-11 13:39:21 -07:00
};
2016-03-03 06:00:54 -08:00
iconv = fetchFromGitHub {
2015-09-11 13:39:21 -07:00
owner = "processone";
2016-03-03 06:00:54 -08:00
repo = "iconv";
2016-02-10 15:36:09 -08:00
rev = "1.0.0";
2016-03-03 06:00:54 -08:00
sha256 = "0dfc23m2lqilj8ixn23wpj5xp1mgajb9b5ch95riigxzxmx97ri9";
2015-09-11 13:39:21 -07:00
};
meck = fetchFromGitHub {
owner = "eproxus";
repo = "meck";
2016-02-10 15:36:09 -08:00
rev = "0.8.2";
sha256 = "0s4qbvryap46cz63awpbv5zzmlcay5pn2lixgmgvcjarqv70cbs7";
2015-09-11 13:39:21 -07:00
};
eredis = fetchFromGitHub {
owner = "wooga";
repo = "eredis";
2016-02-10 15:36:09 -08:00
rev = "v1.0.8";
sha256 = "10fr3kbc2nd2liggsq4y77nfirndzapcxzkjgyp06bpr9cjlvhlm";
2015-09-11 13:39:21 -07:00
};
};
in stdenv.mkDerivation rec {
2016-03-03 06:00:54 -08:00
version = "16.02";
2013-11-01 17:46:30 -07:00
name = "ejabberd-${version}";
2015-09-11 13:39:21 -07:00
src = fetchurl {
2013-11-01 17:46:30 -07:00
url = "http://www.process-one.net/downloads/ejabberd/${version}/${name}.tgz";
2016-03-03 06:00:54 -08:00
sha256 = "0yiai7zyjdcp0ppc5l5p56bxhg273hwfbv41qlbkg32dhr880f4q";
};
2015-09-11 13:39:21 -07:00
nativeBuildInputs = [ fakegit ];
buildInputs = [ erlang openssl expat libyaml ]
++ 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";
depsNames =
2016-03-03 06:00:54 -08:00
[ "lager" "goldrush" "p1_utils" "cache_tab" "fast_tls" "stringprep" "fast_xml" "stun" "esip" "fast_yaml"
"jiffy" "p1_oauth2" "p1_xmlrpc" "luerl"
]
2015-09-11 13:39:21 -07:00
++ lib.optional withMysql "p1_mysql"
++ lib.optional withPgsql "p1_pgsql"
++ lib.optional withSqlite "sqlite3"
++ lib.optional withPam "p1_pam"
2016-03-03 06:00:54 -08:00
++ lib.optional withZlib "ezlib"
2016-02-10 15:36:09 -08:00
++ lib.optionals withRiak [ "hamcrest" "riakc" "riak_pb" "protobuffs" ]
2016-03-03 06:00:54 -08:00
++ lib.optionals withElixir [ "elixir" "rebar_elixir_plugin" ]
++ lib.optional withIconv "iconv"
2015-09-11 13:39:21 -07:00
++ lib.optional withTools "meck"
++ lib.optional withRedis "eredis"
;
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}";
depsPaths = map (x: builtins.getAttr x ejdeps) depsNames;
2016-02-10 15:36:09 -08:00
depsRevs = map (x: x.rev) depsPaths;
2015-09-11 13:39:21 -07:00
enableParallelBuilding = true;
preBuild = ''
mkdir deps
depsPathsA=( $depsPaths )
depsNamesA=( $depsNames )
2016-02-10 15:36:09 -08:00
depsRevsA=( $depsRevs )
2015-09-11 13:39:21 -07:00
for i in {0..${toString (builtins.length depsNames - 1)}}; do
2016-02-10 15:36:09 -08:00
path="deps/''${depsNamesA[$i]}"
cp -R ''${depsPathsA[$i]} "$path"
chmod -R +w "$path"
echo "''${depsRevsA[$i]}" > "$path/.rev"
2015-09-11 13:39:21 -07:00
done
touch deps/.got
patchShebangs .
2016-02-10 15:36:09 -08:00
for i in deps/*; do
[ -x "$i/configure" ] && ( cd "$i"; ./configure ) || true
done
'';
2015-09-11 13:39:21 -07:00
postInstall = ''
sed -i \
-e '2iexport PATH=${ctlpath}:$PATH' \
-e 's,\(^ *FLOCK=\).*,\1${utillinux}/bin/flock,' \
-e 's,\(^ *JOT=\).*,\1,' \
-e 's,\(^ *CONNLOCKDIR=\).*,\1/var/lock/ejabberdctl,' \
$out/sbin/ejabberdctl
2013-11-01 17:46:30 -07:00
'';
meta = {
description = "Open-source XMPP application server written in Erlang";
2016-03-03 06:00:54 -08:00
license = lib.licenses.gpl2;
homepage = http://www.ejabberd.im;
2016-03-03 06:00:54 -08:00
platforms = lib.platforms.linux;
maintainers = [ lib.maintainers.sander lib.maintainers.abbradar ];
};
}