about summary refs log tree commit diff
path: root/nixpkgs/pkgs/servers/search/elasticsearch
diff options
context:
space:
mode:
Diffstat (limited to 'nixpkgs/pkgs/servers/search/elasticsearch')
-rw-r--r--nixpkgs/pkgs/servers/search/elasticsearch/5.x.nix43
-rw-r--r--nixpkgs/pkgs/servers/search/elasticsearch/default.nix72
-rw-r--r--nixpkgs/pkgs/servers/search/elasticsearch/es-classpath-5.x.patch43
-rw-r--r--nixpkgs/pkgs/servers/search/elasticsearch/es-home-5.x.patch31
-rw-r--r--nixpkgs/pkgs/servers/search/elasticsearch/es-home-6.x.patch26
-rw-r--r--nixpkgs/pkgs/servers/search/elasticsearch/plugins.nix68
6 files changed, 283 insertions, 0 deletions
diff --git a/nixpkgs/pkgs/servers/search/elasticsearch/5.x.nix b/nixpkgs/pkgs/servers/search/elasticsearch/5.x.nix
new file mode 100644
index 000000000000..07ebf97ab2bf
--- /dev/null
+++ b/nixpkgs/pkgs/servers/search/elasticsearch/5.x.nix
@@ -0,0 +1,43 @@
+{ stdenv, fetchurl, elk5Version, makeWrapper, jre_headless, utillinux }:
+
+with stdenv.lib;
+
+stdenv.mkDerivation rec {
+  version = elk5Version;
+  name = "elasticsearch-${version}";
+
+  src = fetchurl {
+    url = "https://artifacts.elastic.co/downloads/elasticsearch/${name}.tar.gz";
+    sha256 = "0sm99m4m4mmigj6ll22kyaw7zkp1s2i0mhzx15fzidnybdnlifb4";
+  };
+
+  patches = [ ./es-home-5.x.patch ./es-classpath-5.x.patch ];
+
+  buildInputs = [ makeWrapper jre_headless utillinux ];
+
+  installPhase = ''
+    mkdir -p $out
+    cp -R bin config lib modules plugins $out
+
+    chmod -x $out/bin/*.*
+
+    wrapProgram $out/bin/elasticsearch \
+      --prefix ES_CLASSPATH : "$out/lib/*" \
+      --prefix PATH : "${utillinux}/bin" \
+      --set JAVA_HOME "${jre_headless}" \
+      --set ES_JVM_OPTIONS "$out/config/jvm.options"
+
+    wrapProgram $out/bin/elasticsearch-plugin \
+      --prefix ES_CLASSPATH : "$out/lib/*" \
+      --set JAVA_HOME "${jre_headless}"
+  '';
+
+  meta = {
+    description = "Open Source, Distributed, RESTful Search Engine";
+    license = licenses.asl20;
+    platforms = platforms.unix;
+    maintainers = [
+      maintainers.apeschar
+    ];
+  };
+}
diff --git a/nixpkgs/pkgs/servers/search/elasticsearch/default.nix b/nixpkgs/pkgs/servers/search/elasticsearch/default.nix
new file mode 100644
index 000000000000..d22395e0133a
--- /dev/null
+++ b/nixpkgs/pkgs/servers/search/elasticsearch/default.nix
@@ -0,0 +1,72 @@
+{ elk6Version
+, enableUnfree ? true
+, stdenv
+, fetchurl
+, makeWrapper
+, jre_headless
+, utillinux
+, autoPatchelfHook
+, zlib
+}:
+
+with stdenv.lib;
+
+stdenv.mkDerivation (rec {
+  version = elk6Version;
+  name = "elasticsearch-${optionalString (!enableUnfree) "oss-"}${version}";
+
+  src = fetchurl {
+    url = "https://artifacts.elastic.co/downloads/elasticsearch/${name}.tar.gz";
+    sha256 =
+      if enableUnfree
+      then "096i8xiy7mfwlslym9mkjb2f5vqdcqhk65583526rcybqxc2zkqp"
+      else "0j3q02c4rw8272w07hm64sk5ssmj4gj8s3qigsbrq5pgf8b03fvs";
+  };
+
+  patches = [ ./es-home-6.x.patch ];
+
+  postPatch = ''
+    substituteInPlace bin/elasticsearch-env --replace \
+      "ES_CLASSPATH=\"\$ES_HOME/lib/\*\"" \
+      "ES_CLASSPATH=\"$out/lib/*\""
+
+    substituteInPlace bin/elasticsearch-cli --replace \
+      "ES_CLASSPATH=\"\$ES_CLASSPATH:\$ES_HOME/\$additional_classpath_directory/\*\"" \
+      "ES_CLASSPATH=\"\$ES_CLASSPATH:$out/\$additional_classpath_directory/\*\""
+  '';
+
+  buildInputs = [ makeWrapper jre_headless utillinux ]
+             ++ optional enableUnfree zlib;
+
+  installPhase = ''
+    mkdir -p $out
+    cp -R bin config lib modules plugins $out
+
+    chmod -x $out/bin/*.*
+
+    wrapProgram $out/bin/elasticsearch \
+      --prefix PATH : "${utillinux}/bin/" \
+      --set JAVA_HOME "${jre_headless}"
+
+    wrapProgram $out/bin/elasticsearch-plugin --set JAVA_HOME "${jre_headless}"
+  '';
+
+  passthru = { inherit enableUnfree; };
+
+  meta = {
+    description = "Open Source, Distributed, RESTful Search Engine";
+    license = if enableUnfree then licenses.elastic else licenses.asl20;
+    platforms = platforms.unix;
+    maintainers = with maintainers; [ apeschar basvandijk ];
+  };
+} // optionalAttrs enableUnfree {
+  dontPatchELF = true;
+  nativeBuildInputs = [ autoPatchelfHook ];
+  runtimeDependencies = [ zlib ];
+  postFixup = ''
+    for exe in $(find $out/modules/x-pack-ml/platform/linux-x86_64/bin -executable -type f); do
+      echo "patching $exe..."
+      patchelf --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" "$exe"
+    done
+  '';
+})
diff --git a/nixpkgs/pkgs/servers/search/elasticsearch/es-classpath-5.x.patch b/nixpkgs/pkgs/servers/search/elasticsearch/es-classpath-5.x.patch
new file mode 100644
index 000000000000..ccdca1e53afc
--- /dev/null
+++ b/nixpkgs/pkgs/servers/search/elasticsearch/es-classpath-5.x.patch
@@ -0,0 +1,43 @@
+diff -rupN a/bin/elasticsearch b/bin/elasticsearch
+--- a/bin/elasticsearch	2017-05-17 10:53:49.444487071 +0200
++++ b/bin/elasticsearch	2017-05-17 10:55:52.755081523 +0200
+@@ -129,12 +129,7 @@ ES_JAVA_OPTS="$(parse_jvm_options "$ES_J
+ # If an include wasn't specified in the environment, then search for one...
+ if [ "x$ES_INCLUDE" = "x" ]; then
+     # Locations (in order) to use when searching for an include file.
+-    for include in /usr/share/elasticsearch/elasticsearch.in.sh \
+-                   /usr/local/share/elasticsearch/elasticsearch.in.sh \
+-                   /opt/elasticsearch/elasticsearch.in.sh \
+-                   ~/.elasticsearch.in.sh \
+-                   "$ES_HOME/bin/elasticsearch.in.sh" \
+-                   "`dirname "$0"`"/elasticsearch.in.sh; do
++    for include in "`dirname "$0"`"/elasticsearch.in.sh; do
+         if [ -r "$include" ]; then
+             . "$include"
+             break
+diff -rupN a/bin/elasticsearch.in.sh b/bin/elasticsearch.in.sh
+--- a/bin/elasticsearch.in.sh	2017-04-28 19:41:47.000000000 +0200
++++ b/bin/elasticsearch.in.sh	2017-05-17 10:56:49.303519788 +0200
+@@ -1,13 +1 @@
+ #!/bin/bash
+-
+-# check in case a user was using this mechanism
+-if [ "x$ES_CLASSPATH" != "x" ]; then
+-    cat >&2 << EOF
+-Error: Don't modify the classpath with ES_CLASSPATH. Best is to add
+-additional elements via the plugin mechanism, or if code must really be
+-added to the main classpath, add jars to lib/ (unsupported).
+-EOF
+-    exit 1
+-fi
+-
+-ES_CLASSPATH="$ES_HOME/lib/*"
+diff -rupN a/bin/elasticsearch-plugin b/bin/elasticsearch-plugin
+--- a/bin/elasticsearch-plugin	2018-04-13 01:21:55.000000000 +0900
++++ b/bin/elasticsearch-plugin	2018-06-28 19:08:54.700969245 +0900
+@@ -88,4 +88,4 @@ if [ -e "$CONF_DIR" ]; then
+   path_props=("${path_props[@]}" -Des.path.conf="$CONF_DIR")
+ fi
+ 
+-exec "$JAVA" $ES_JAVA_OPTS -Delasticsearch "${path_props[@]}" -cp "$ES_HOME/lib/*" org.elasticsearch.plugins.PluginCli "${args[@]}"
++exec "$JAVA" $ES_JAVA_OPTS -Delasticsearch "${path_props[@]}" -cp "$ES_CLASSPATH" org.elasticsearch.plugins.PluginCli "${args[@]}"
diff --git a/nixpkgs/pkgs/servers/search/elasticsearch/es-home-5.x.patch b/nixpkgs/pkgs/servers/search/elasticsearch/es-home-5.x.patch
new file mode 100644
index 000000000000..cee0137312f1
--- /dev/null
+++ b/nixpkgs/pkgs/servers/search/elasticsearch/es-home-5.x.patch
@@ -0,0 +1,31 @@
+diff -rupN a/bin/elasticsearch b/bin/elasticsearch
+--- a/bin/elasticsearch	2017-05-17 10:53:42.214686741 +0200
++++ b/bin/elasticsearch	2017-05-17 10:53:49.444487071 +0200
+@@ -105,7 +105,11 @@ while [ -h "$SCRIPT" ] ; do
+ done
+ 
+ # determine elasticsearch home
+-ES_HOME=`dirname "$SCRIPT"`/..
++
++if [ -z "$ES_HOME" ]; then
++    echo "You must set the ES_HOME var" >&2
++    exit 1
++fi
+ 
+ # make ELASTICSEARCH_HOME absolute
+ ES_HOME=`cd "$ES_HOME"; pwd`
+diff -rupN a/bin/elasticsearch-plugin b/bin/elasticsearch-plugin
+--- a/bin/elasticsearch-plugin	2017-05-17 10:53:42.214686741 +0200
++++ b/bin/elasticsearch-plugin	2017-05-17 10:53:49.445487044 +0200
+@@ -16,7 +16,10 @@ while [ -h "$SCRIPT" ] ; do
+ done
+ 
+ # determine elasticsearch home
+-ES_HOME=`dirname "$SCRIPT"`/..
++if [ -z "$ES_HOME" ]; then
++    echo "You must set the ES_HOME var" >&2
++    exit 1
++fi
+ 
+ # make ELASTICSEARCH_HOME absolute
+ ES_HOME=`cd "$ES_HOME"; pwd`
diff --git a/nixpkgs/pkgs/servers/search/elasticsearch/es-home-6.x.patch b/nixpkgs/pkgs/servers/search/elasticsearch/es-home-6.x.patch
new file mode 100644
index 000000000000..aba8d396a69c
--- /dev/null
+++ b/nixpkgs/pkgs/servers/search/elasticsearch/es-home-6.x.patch
@@ -0,0 +1,26 @@
+diff -Naur a/bin/elasticsearch-env b/bin/elasticsearch-env
+--- a/bin/elasticsearch-env	2017-12-12 13:31:51.000000000 +0100
++++ b/bin/elasticsearch-env	2017-12-18 19:51:12.282809695 +0100
+@@ -19,18 +19,10 @@
+   fi
+ done
+ 
+-# determine Elasticsearch home; to do this, we strip from the path until we find
+-# bin, and then strip bin (there is an assumption here that there is no nested
+-# directory under bin also named bin)
+-ES_HOME=`dirname "$SCRIPT"`
+-
+-# now make ES_HOME absolute
+-ES_HOME=`cd "$ES_HOME"; pwd`
+-
+-while [ "`basename "$ES_HOME"`" != "bin" ]; do
+-  ES_HOME=`dirname "$ES_HOME"`
+-done
+-ES_HOME=`dirname "$ES_HOME"`
++if [ -z "$ES_HOME" ]; then
++    echo "You must set the ES_HOME var" >&2
++    exit 1
++fi
+ 
+ # now set the classpath
+ ES_CLASSPATH="$ES_HOME/lib/*"
diff --git a/nixpkgs/pkgs/servers/search/elasticsearch/plugins.nix b/nixpkgs/pkgs/servers/search/elasticsearch/plugins.nix
new file mode 100644
index 000000000000..4451b0104464
--- /dev/null
+++ b/nixpkgs/pkgs/servers/search/elasticsearch/plugins.nix
@@ -0,0 +1,68 @@
+{ pkgs,  stdenv, fetchurl, unzip, elasticsearch-oss, javaPackages, elk6Version }:
+
+let
+  esPlugin = a@{
+    pluginName,
+    installPhase ? ''
+      mkdir -p $out/config
+      mkdir -p $out/plugins
+      ES_HOME=$out ${elasticsearch-oss}/bin/elasticsearch-plugin install --batch -v file://$src
+    '',
+    ...
+  }:
+    stdenv.mkDerivation (a // {
+      inherit installPhase;
+      unpackPhase = "true";
+      buildInputs = [ unzip ];
+      meta = a.meta // {
+        platforms = elasticsearch-oss.meta.platforms;
+        maintainers = (a.meta.maintainers or []) ++ (with stdenv.lib.maintainers; [ offline ]);
+      };
+    });
+in {
+
+  elasticsearch_analysis_lemmagen = esPlugin rec {
+    name = "elasticsearch-analysis-lemmagen-${version}";
+    pluginName = "elasticsearch-analysis-lemmagen";
+    version = "${elk6Version}";
+    src = fetchurl {
+      url = "https://github.com/vhyza/elasticsearch-analysis-lemmagen/releases/download/v${version}/${name}-plugin.zip";
+      sha256 = "0299ldqwjn1gn44yyjiqjrxvs6mlclhzl1dbn6xlgg1a2lkaal4v";
+    };
+    meta = with stdenv.lib; {
+      homepage = https://github.com/vhyza/elasticsearch-analysis-lemmagen;
+      description = "LemmaGen Analysis plugin provides jLemmaGen lemmatizer as Elasticsearch token filter";
+      license = licenses.asl20;
+    };
+  };
+
+  discovery-ec2 = esPlugin rec {
+    name = "elasticsearch-discovery-ec2-${version}";
+    pluginName = "discovery-ec2";
+    version = "${elk6Version}";
+    src = pkgs.fetchurl {
+      url = "https://artifacts.elastic.co/downloads/elasticsearch-plugins/discovery-ec2/discovery-ec2-${elk6Version}.zip";
+      sha256 = "1mg9knbc4r21kaiqnmkd8nzf2i23w5zxqnxyz484q0l2jf4hlkq1";
+    };
+    meta = with stdenv.lib; {
+      homepage = https://github.com/elastic/elasticsearch/tree/master/plugins/discovery-ec2;
+      description = "The EC2 discovery plugin uses the AWS API for unicast discovery.";
+      license = licenses.asl20;
+    };
+  };
+
+  search_guard = esPlugin rec {
+    name = "elastic-search-guard-${version}";
+    pluginName = "search-guard";
+    version = "${elk6Version}-23.2";
+    src = fetchurl rec {
+      url = "mirror://maven/com/floragunn/search-guard-6/${version}/search-guard-6-${version}.zip";
+      sha256 = "05310wyxzhylxr0dfgzr10pb0pak30ry8r97g49n6iqj8dw3csnb";
+    };
+    meta = with stdenv.lib; {
+      homepage = https://github.com/floragunncom/search-guard;
+      description = "Plugin to fetch data from JDBC sources for indexing into Elasticsearch";
+      license = licenses.asl20;
+    };
+  };
+}