1{ stdenv, lib, fetchurl, zip, unzip, makeWrapper
2, jzmq, jdk, python
3, logsDir ? "", confFile ? "", extraLibraryPaths ? [], extraJars ? [] }:
4
5stdenv.mkDerivation rec {
6 name = "apache-storm-" + version;
7 version = "1.0.1";
8 src = fetchurl {
9 url =
10 "mirror://apache/storm/${name}/${name}.tar.gz";
11 sha256 = "1gr00s0fhf8ci0faf3x5dinkiw9mlnc1x1vqki8cfszvij6w0x0m";
12 };
13
14 buildInputs = [ zip unzip jzmq ];
15
16 installPhase = ''
17 mkdir -p $out/share/${name}
18 mv public $out/docs
19 mv examples $out/share/${name}/.
20
21 rm -f lib/jzmq* || exit 1
22 mv lib $out/.
23 mv external extlib* $out/lib/.
24 mv conf bin $out/.
25 mv log4j2 $out/conf/.
26 '';
27
28 fixupPhase = ''
29 # Fix python reference
30 sed -i \
31 -e '19iPYTHON=${python}/bin/python' \
32 -e 's|#!/usr/bin/.*python|#!${python}/bin/python|' \
33 $out/bin/storm
34 sed -i \
35 -e 's|#!/usr/bin/.*python|#!${python}/bin/python|' \
36 -e "s|STORM_CONF_DIR = .*|STORM_CONF_DIR = os.getenv('STORM_CONF_DIR','$out/conf')|" \
37 -e 's|STORM_LOG4J2_CONF_DIR =.*|STORM_LOG4J2_CONF_DIR = os.path.join(STORM_CONF_DIR, "log4j2")|' \
38 $out/bin/storm.py
39 # Default jdk location
40 sed -i -e 's|#.*export JAVA_HOME=.*|export JAVA_HOME="${jdk.home}"|' \
41 $out/conf/storm-env.sh
42 unzip $out/lib/storm-core-${version}.jar defaults.yaml;
43 zip -d $out/lib/storm-core-${version}.jar defaults.yaml;
44 sed -i \
45 -e 's|java.library.path: .*|java.library.path: "${jzmq}/lib:${lib.concatStringsSep ":" extraLibraryPaths}"|' \
46 -e 's|storm.log4j2.conf.dir: .*|storm.log4j2.conf.dir: "conf/log4j2"|' \
47 defaults.yaml
48 ${if confFile != "" then ''cat ${confFile} >> defaults.yaml'' else ""}
49 mv defaults.yaml $out/conf;
50
51 # Link to jzmq jar and extra jars
52 cd $out/lib;
53 ln -s ${jzmq}/share/java/*.jar;
54 ${lib.concatMapStrings (jar: "ln -s ${jar};\n") extraJars}
55 '';
56
57 dontStrip = true;
58
59 meta = with stdenv.lib; {
60 homepage = "http://storm.apache.org";
61 description = "Distributed realtime computation system";
62 license = licenses.asl20;
63 maintainers = with maintainers; [ edwtjo vizanto ];
64 platforms = with platforms; unix;
65 };
66}