2020-04-24 23:36:52 +00:00
|
|
|
{ elk7Version
|
|
|
|
, enableUnfree ? true
|
2021-09-18 10:52:07 +00:00
|
|
|
, lib
|
|
|
|
, stdenv
|
2020-04-24 23:36:52 +00:00
|
|
|
, fetchurl
|
|
|
|
, makeWrapper
|
|
|
|
, jre_headless
|
2021-09-18 10:52:07 +00:00
|
|
|
, util-linux
|
|
|
|
, gnugrep
|
|
|
|
, coreutils
|
2020-04-24 23:36:52 +00:00
|
|
|
, autoPatchelfHook
|
|
|
|
, zlib
|
|
|
|
}:
|
|
|
|
|
2021-01-15 22:18:51 +00:00
|
|
|
with lib;
|
2020-04-24 23:36:52 +00:00
|
|
|
let
|
|
|
|
info = splitString "-" stdenv.hostPlatform.system;
|
|
|
|
arch = elemAt info 0;
|
|
|
|
plat = elemAt info 1;
|
|
|
|
shas =
|
|
|
|
if enableUnfree
|
|
|
|
then {
|
2021-09-18 10:52:07 +00:00
|
|
|
x86_64-linux = "sha256-O3rjtvXyJI+kRBqiz2U2OMkCIQj4E+AIHaE8N4o14R4=";
|
|
|
|
x86_64-darwin = "sha256-AwuY2yMxf+v7U5/KD3Cf+Hv6ijjySEyj6pzF3RCsg24=";
|
2020-04-24 23:36:52 +00:00
|
|
|
}
|
|
|
|
else {
|
2021-09-18 10:52:07 +00:00
|
|
|
x86_64-linux = "sha256-cJrdkFIFgAI6wfQh34Z8yFuLrOCOKzgOsWZhU3S/3NQ=";
|
|
|
|
x86_64-darwin = "sha256-OhMVOdXei9D9cH+O5tBhdKvZ05TsImjMqUUsucRyWMo=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
in
|
|
|
|
stdenv.mkDerivation (rec {
|
|
|
|
version = elk7Version;
|
2021-08-05 21:33:18 +00:00
|
|
|
pname = "elasticsearch${optionalString (!enableUnfree) "-oss"}";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
src = fetchurl {
|
2021-08-05 21:33:18 +00:00
|
|
|
url = "https://artifacts.elastic.co/downloads/elasticsearch/${pname}-${version}-${plat}-${arch}.tar.gz";
|
2020-04-24 23:36:52 +00:00
|
|
|
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/*\""
|
|
|
|
'';
|
|
|
|
|
2021-03-09 03:18:52 +00:00
|
|
|
nativeBuildInputs = [ makeWrapper ];
|
|
|
|
buildInputs = [ jre_headless util-linux ]
|
2021-09-18 10:52:07 +00:00
|
|
|
++ optional enableUnfree zlib;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
mkdir -p $out
|
|
|
|
cp -R bin config lib modules plugins $out
|
|
|
|
|
|
|
|
chmod +x $out/bin/*
|
|
|
|
|
2021-09-18 10:52:07 +00:00
|
|
|
substituteInPlace $out/bin/elasticsearch \
|
|
|
|
--replace 'bin/elasticsearch-keystore' "$out/bin/elasticsearch-keystore"
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
wrapProgram $out/bin/elasticsearch \
|
2020-11-24 20:58:05 +00:00
|
|
|
--prefix PATH : "${makeBinPath [ util-linux coreutils gnugrep ]}" \
|
2020-04-24 23:36:52 +00:00
|
|
|
--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;
|
2021-03-09 03:18:52 +00:00
|
|
|
nativeBuildInputs = [ makeWrapper autoPatchelfHook ];
|
2020-04-24 23:36:52 +00:00
|
|
|
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
|
|
|
|
'';
|
|
|
|
})
|