depot/third_party/nixpkgs/pkgs/servers/search/elasticsearch/7.x.nix
Default email ce641f4048 Project import generated by Copybara.
GitOrigin-RevId: bc5d68306b40b8522ffb69ba6cff91898c2fbbff
2021-12-06 17:07:01 +01:00

77 lines
2.1 KiB
Nix

{ elk7Version
, lib
, stdenv
, fetchurl
, makeWrapper
, jre_headless
, util-linux
, gnugrep
, coreutils
, autoPatchelfHook
, zlib
}:
with lib;
let
info = splitString "-" stdenv.hostPlatform.system;
arch = elemAt info 0;
plat = elemAt info 1;
shas =
{
x86_64-linux = "1ld7656b37l67vi4pyv0il865b168niqnbd4hzbvdnwrm35prp10";
x86_64-darwin = "11b180y11xw5q01l7aw6lyn15lp9ks8xmakjg1j7gp3z6c90hpn3";
aarch64-linux = "0s4ph79x17f90jk31wjwk259dk9dmhnmnkxdcn77m191wvf6m3wy";
};
in
stdenv.mkDerivation rec {
pname = "elasticsearch";
version = elk7Version;
src = fetchurl {
url = "https://artifacts.elastic.co/downloads/elasticsearch/${pname}-${version}-${plat}-${arch}.tar.gz";
sha256 = shas.${stdenv.hostPlatform.system} or (throw "Unknown architecture");
};
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/*\""
'';
nativeBuildInputs = [ autoPatchelfHook makeWrapper ];
buildInputs = [ jre_headless util-linux zlib ];
runtimeDependencies = [ zlib ];
installPhase = ''
mkdir -p $out
cp -R bin config lib modules plugins $out
chmod +x $out/bin/*
substituteInPlace $out/bin/elasticsearch \
--replace 'bin/elasticsearch-keystore' "$out/bin/elasticsearch-keystore"
wrapProgram $out/bin/elasticsearch \
--prefix PATH : "${makeBinPath [ util-linux coreutils gnugrep ]}" \
--set JAVA_HOME "${jre_headless}"
wrapProgram $out/bin/elasticsearch-plugin --set JAVA_HOME "${jre_headless}"
'';
passthru = { enableUnfree = true; };
meta = {
description = "Open Source, Distributed, RESTful Search Engine";
license = licenses.elastic;
platforms = platforms.unix;
maintainers = with maintainers; [ apeschar basvandijk ];
};
}