nixpkgs/pkgs/servers/search/elasticsearch/7.x.nix
Andrew Childs 8fba8ef596 elasticsearch7: remove manual elf patching
The options as specified were not a coherent set. There were three
things to consider: autoPatchelfHook, the regular rpath
fixup (controlled by dontPatchELF) and the elf interpreter rewrite in
the postFixup hook.

The autoPatchelfHook will set the interpreter, so the explicit
invocation of patchelf to do so in postFixup should not be required.

The autoPatchelfHook will rewrite rpaths entirely, so disabling the
rpath minimizing via dontPatchELF should have no effect.
2021-11-03 11:37:07 +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 ];
};
}