nixpkgs/pkgs/development/libraries/libstemmer/default.nix
Artturin 154a55389c 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)
2022-08-31 16:50:34 +03:00

41 lines
1 KiB
Nix

{ lib, stdenv, fetchFromGitHub, perl, buildPackages }:
stdenv.mkDerivation rec {
pname = "libstemmer";
version = "2.2.0";
src = fetchFromGitHub {
owner = "snowballstem";
repo = "snowball";
rev = "v${version}";
sha256 = "sha256-qXrypwv/I+5npvGHGsHveijoui0ZnoGYhskCfLkewVE=";
};
nativeBuildInputs = [ perl ];
prePatch = ''
patchShebangs .
'' + lib.optionalString (!stdenv.buildPlatform.canExecute stdenv.hostPlatform) ''
substituteInPlace GNUmakefile \
--replace './snowball' '${lib.getBin buildPackages.libstemmer}/bin/snowball'
'';
makeTarget = "libstemmer.a";
installPhase = ''
runHook preInstall
install -Dt $out/lib libstemmer.a
install -Dt $out/include include/libstemmer.h
install -Dt $out/bin {snowball,stemwords}
runHook postInstall
'';
meta = with lib; {
description = "Snowball Stemming Algorithms";
homepage = "https://snowballstem.org/";
license = licenses.bsd3;
maintainers = with maintainers; [ fpletz ];
platforms = platforms.all;
};
}