From 7eb4d306fbb1e3d4fd3af47530c8f7d2b74ef523 Mon Sep 17 00:00:00 2001 From: Jaka Hudoklin Date: Sat, 5 Jul 2014 12:09:53 +0200 Subject: [PATCH] elasticsearch: add support for plugins --- .../modules/services/search/elasticsearch.nix | 18 ++++++- pkgs/servers/search/elasticsearch/default.nix | 1 + pkgs/servers/search/elasticsearch/plugins.nix | 53 +++++++++++++++++++ pkgs/top-level/all-packages.nix | 4 ++ 4 files changed, 75 insertions(+), 1 deletion(-) create mode 100644 pkgs/servers/search/elasticsearch/plugins.nix diff --git a/nixos/modules/services/search/elasticsearch.nix b/nixos/modules/services/search/elasticsearch.nix index eeae11dc4ff3..c99d1e229677 100644 --- a/nixos/modules/services/search/elasticsearch.nix +++ b/nixos/modules/services/search/elasticsearch.nix @@ -21,6 +21,11 @@ let ]; }; + esPlugins = pkgs.buildEnv { + name = "elasticsearch-plugins"; + paths = cfg.plugins; + }; + in { ###### interface @@ -101,6 +106,12 @@ in { example = [ "-Djava.net.preferIPv4Stack=true" ]; }; + plugins = mkOption { + description = "Extra elasticsearch plugins"; + default = []; + type = types.listOf types.package; + }; + }; ###### implementation @@ -111,14 +122,19 @@ in { wantedBy = [ "multi-user.target" ]; after = [ "network-interfaces.target" ]; environment = { ES_HOME = cfg.dataDir; }; + path = [ pkgs.elasticsearch ]; serviceConfig = { - ExecStart = "${pkgs.elasticsearch}/bin/elasticsearch -Des.path.conf=${configDir} ${toString cfg.extraCmdLineOptions}"; + ExecStart = "elasticsearch -Des.path.conf=${configDir} ${toString cfg.extraCmdLineOptions}"; User = "elasticsearch"; PermissionsStartOnly = true; }; preStart = '' mkdir -m 0700 -p ${cfg.dataDir} if [ "$(id -u)" = 0 ]; then chown -R elasticsearch ${cfg.dataDir}; fi + + # Install plugins + rm ${cfg.dataDir}/plugins || true + ln -s ${esPlugins}/plugins ${cfg.dataDir}/plugins ''; }; diff --git a/pkgs/servers/search/elasticsearch/default.nix b/pkgs/servers/search/elasticsearch/default.nix index 765ed3ee8e95..76e416d64724 100644 --- a/pkgs/servers/search/elasticsearch/default.nix +++ b/pkgs/servers/search/elasticsearch/default.nix @@ -33,5 +33,6 @@ stdenv.mkDerivation rec { meta = { description = "Open Source, Distributed, RESTful Search Engine"; license = "ASL2.0"; + platforms = platforms.unix; }; } diff --git a/pkgs/servers/search/elasticsearch/plugins.nix b/pkgs/servers/search/elasticsearch/plugins.nix new file mode 100644 index 000000000000..4d98ce6a71f9 --- /dev/null +++ b/pkgs/servers/search/elasticsearch/plugins.nix @@ -0,0 +1,53 @@ +{ pkgs, stdenv, fetchurl, unzip, elasticsearch }: + +with pkgs.lib; + +let + esPlugin = a@{ + pluginName, + installPhase ? '' + mkdir -p $out + ES_HOME=$out ${elasticsearch}/bin/elasticsearch-plugin --install ${pluginName} --url file://$src + '', + ... + }: + stdenv.mkDerivation (a // { + inherit installPhase; + unpackPhase = "true"; + buildInputs = [ unzip ]; + meta = a.meta // { + platforms = elasticsearch.meta.platforms; + maintainers = a.maintainers ++ [ maintainers.offline ]; + }; + }); +in { + elasticsearch_river_jdbc = esPlugin rec { + name = "elasticsearch-river-jdbc-${version}"; + pluginName = "jdbc"; + version = "1.2.1.1"; + src = fetchurl { + url = "http://xbib.org/repository/org/xbib/elasticsearch/plugin/elasticsearch-river-jdbc/${version}/${name}-plugin.zip"; + sha1 = "68e7e1fdf45d0e5852b21610a84740595223ea11"; + }; + meta = { + homepage = "https://github.com/jprante/elasticsearch-river-jdbc"; + description = "Plugin to fetch data from JDBC sources for indexing into Elasticsearch"; + license = licenses.asl20; + }; + }; + + elasticsearch_analisys_lemmagen = esPlugin rec { + name = "elasticsearch-analysis-lemmagen-${version}"; + pluginName = "elasticsearch-analysis-lemmagen"; + version = "0.1"; + src = fetchurl { + url = "https://github.com/vhyza/elasticsearch-analysis-lemmagen/releases/download/v${version}/${name}-plugin.zip"; + sha256 = "bf7bf5ce3ccdd3afecd0e18cd6fce1ef56f824e41f4ef50553ae598caa5c366d"; + }; + meta = { + homepage = "https://github.com/vhyza/elasticsearch-analysis-lemmagen"; + description = "LemmaGen Analysis plugin provides jLemmaGen lemmatizer as Elasticsearch token filter"; + license = licenses.asl20; + }; + }; +} diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 2d321fd2d802..47c2cc39d6cd 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -954,6 +954,10 @@ let elasticsearch = callPackage ../servers/search/elasticsearch { }; + elasticsearchPlugins = recurseIntoAttrs ( + callPackage ../servers/search/elasticsearch/plugins.nix { } + ); + emv = callPackage ../tools/misc/emv { }; enblendenfuse = callPackage ../tools/graphics/enblend-enfuse {