libstemmer: install and use snowball binary from buildPackages

libstemmer-aarch64-unknown-linux-gnu> ./snowball algorithms/arabic.sbl -o src_c/stem_UTF_8_arabic -eprefix arabic_UTF_8_ -r ../runtime -u
libstemmer-aarch64-unknown-linux-gnu> /nix/store/p7bpdnxqd3i5hwm92mrscf7mvxk66404-bash-5.1-p16/bin/bash: line 4: ./snowball: cannot execute binary file: Exec format error

ref https://github.com/archlinux/svntogit-packages/blob/packages/snowball/trunk/PKGBUILD

for emulator alternative

ref: 4976c61b3a/srcpkgs/snowball/template (L16-L21)
This commit is contained in:
Artturin 2022-08-30 22:19:20 +03:00
parent 118b5d13a1
commit 154a55389c

View File

@ -1,4 +1,4 @@
{ lib, stdenv, fetchFromGitHub, perl }:
{ lib, stdenv, fetchFromGitHub, perl, buildPackages }:
stdenv.mkDerivation rec {
pname = "libstemmer";
@ -15,6 +15,9 @@ stdenv.mkDerivation rec {
prePatch = ''
patchShebangs .
'' + lib.optionalString (!stdenv.buildPlatform.canExecute stdenv.hostPlatform) ''
substituteInPlace GNUmakefile \
--replace './snowball' '${lib.getBin buildPackages.libstemmer}/bin/snowball'
'';
makeTarget = "libstemmer.a";
@ -23,6 +26,7 @@ stdenv.mkDerivation rec {
runHook preInstall
install -Dt $out/lib libstemmer.a
install -Dt $out/include include/libstemmer.h
install -Dt $out/bin {snowball,stemwords}
runHook postInstall
'';