From 4bc9e8a785b9e8754ca533f64df30a040b195d30 Mon Sep 17 00:00:00 2001 From: Markus Wotringer Date: Fri, 4 Dec 2015 01:12:25 +0100 Subject: [PATCH] elasticsearch2: init at 2.2.0 changes by @globin: * updated 2.1.0 to 2.2.0 * moved to a new derivation closes #11446 Signed-off-by: Robin Gloster --- .../modules/services/search/elasticsearch.nix | 13 ++++-- pkgs/servers/search/elasticsearch/2.x.nix | 41 +++++++++++++++++++ .../search/elasticsearch/es-home-2.x.patch | 31 ++++++++++++++ pkgs/top-level/all-packages.nix | 1 + 4 files changed, 82 insertions(+), 4 deletions(-) create mode 100644 pkgs/servers/search/elasticsearch/2.x.nix create mode 100644 pkgs/servers/search/elasticsearch/es-home-2.x.patch diff --git a/nixos/modules/services/search/elasticsearch.nix b/nixos/modules/services/search/elasticsearch.nix index 356cfd409ad4..31332489a784 100644 --- a/nixos/modules/services/search/elasticsearch.nix +++ b/nixos/modules/services/search/elasticsearch.nix @@ -9,6 +9,8 @@ let network.host: ${cfg.listenAddress} network.port: ${toString cfg.port} network.tcp.port: ${toString cfg.tcp_port} + # TODO: find a way to enable security manager + security.manager.enabled: false cluster.name: ${cfg.cluster_name} ${cfg.extraConf} ''; @@ -39,8 +41,8 @@ in { package = mkOption { description = "Elasticsearch package to use."; - default = pkgs.elasticsearch; - defaultText = "pkgs.elasticsearch"; + default = pkgs.elasticsearch2; + defaultText = "pkgs.elasticsearch2"; type = types.package; }; @@ -129,7 +131,9 @@ in { wantedBy = [ "multi-user.target" ]; after = [ "network-interfaces.target" ]; path = [ pkgs.inetutils ]; - environment = { ES_HOME = cfg.dataDir; }; + environment = { + ES_HOME = cfg.dataDir; + }; serviceConfig = { ExecStart = "${cfg.package}/bin/elasticsearch -Des.path.conf=${configDir} ${toString cfg.extraCmdLineOptions}"; User = "elasticsearch"; @@ -137,10 +141,11 @@ in { }; preStart = '' mkdir -m 0700 -p ${cfg.dataDir} - if [ "$(id -u)" = 0 ]; then chown -R elasticsearch ${cfg.dataDir}; fi # Install plugins ln -sfT ${esPlugins}/plugins ${cfg.dataDir}/plugins + ln -sfT ${cfg.package}/lib ${cfg.dataDir}/lib + if [ "$(id -u)" = 0 ]; then chown -R elasticsearch ${cfg.dataDir}; fi ''; postStart = mkBefore '' until ${pkgs.curl}/bin/curl -s -o /dev/null ${cfg.listenAddress}:${toString cfg.port}; do diff --git a/pkgs/servers/search/elasticsearch/2.x.nix b/pkgs/servers/search/elasticsearch/2.x.nix new file mode 100644 index 000000000000..a37703ae7fd7 --- /dev/null +++ b/pkgs/servers/search/elasticsearch/2.x.nix @@ -0,0 +1,41 @@ +{ stdenv, fetchurl, makeWrapper, jre, utillinux, getopt }: + +with stdenv.lib; + +stdenv.mkDerivation rec { + version = "2.2.0"; + name = "elasticsearch-${version}"; + + src = fetchurl { + url = "https://download.elasticsearch.org/elasticsearch/release/org/elasticsearch/distribution/tar/elasticsearch/${version}/${name}.tar.gz"; + sha256 = "0c2d0mpcr8lpvifvgp2pfj7avdi7fa8a5vib0gqdap7mw60wqw7d"; + }; + + patches = [ ./es-home-2.x.patch ]; + + buildInputs = [ makeWrapper jre ] ++ + (if (!stdenv.isDarwin) then [utillinux] else [getopt]); + + installPhase = '' + mkdir -p $out + cp -R bin config lib $out + + # don't want to have binary with name plugin + mv $out/bin/plugin $out/bin/elasticsearch-plugin + wrapProgram $out/bin/elasticsearch ${if (!stdenv.isDarwin) + then ''--prefix PATH : "${utillinux}/bin/"'' + else ''--prefix PATH : "${getopt}/bin"''} \ + --set JAVA_HOME "${jre}" + wrapProgram $out/bin/elasticsearch-plugin --set JAVA_HOME "${jre}" + ''; + + meta = { + description = "Open Source, Distributed, RESTful Search Engine"; + license = licenses.asl20; + platforms = platforms.unix; + maintainers = [ + maintainers.offline + maintainers.markWot + ]; + }; +} diff --git a/pkgs/servers/search/elasticsearch/es-home-2.x.patch b/pkgs/servers/search/elasticsearch/es-home-2.x.patch new file mode 100644 index 000000000000..0c80e8651145 --- /dev/null +++ b/pkgs/servers/search/elasticsearch/es-home-2.x.patch @@ -0,0 +1,31 @@ +diff -rupN a/bin/elasticsearch b/bin/elasticsearch +--- a/bin/elasticsearch 2015-11-18 21:48:18.000000000 +0100 ++++ b/bin/elasticsearch 2015-12-04 00:52:21.032475098 +0100 +@@ -72,7 +72,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/plugin b/bin/plugin +--- a/bin/plugin 2015-11-18 21:48:18.000000000 +0100 ++++ b/bin/plugin 2015-12-04 00:52:55.947453619 +0100 +@@ -17,7 +17,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/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 21dbbd6e9960..5e8312764dda 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -1437,6 +1437,7 @@ let evemu = callPackage ../tools/system/evemu { }; elasticsearch = callPackage ../servers/search/elasticsearch { }; + elasticsearch2 = callPackage ../servers/search/elasticsearch/2.x.nix { }; elasticsearchPlugins = recurseIntoAttrs ( callPackage ../servers/search/elasticsearch/plugins.nix { }