1{ lib, stdenv, fetchFromGitHub, perl, buildPackages }:
2
3stdenv.mkDerivation rec {
4 pname = "libstemmer";
5 version = "2.2.0";
6
7 src = fetchFromGitHub {
8 owner = "snowballstem";
9 repo = "snowball";
10 rev = "v${version}";
11 sha256 = "sha256-qXrypwv/I+5npvGHGsHveijoui0ZnoGYhskCfLkewVE=";
12 };
13
14 nativeBuildInputs = [ perl ];
15
16 prePatch = ''
17 patchShebangs .
18 '' + lib.optionalString (!stdenv.buildPlatform.canExecute stdenv.hostPlatform) ''
19 substituteInPlace GNUmakefile \
20 --replace './snowball' '${lib.getBin buildPackages.libstemmer}/bin/snowball'
21 '';
22
23 makeTarget = "libstemmer.a";
24
25 installPhase = ''
26 runHook preInstall
27 install -Dt $out/lib libstemmer.a
28 install -Dt $out/include include/libstemmer.h
29 install -Dt $out/bin {snowball,stemwords}
30 runHook postInstall
31 '';
32
33 meta = with lib; {
34 description = "Snowball Stemming Algorithms";
35 homepage = "https://snowballstem.org/";
36 license = licenses.bsd3;
37 maintainers = with maintainers; [ fpletz ];
38 platforms = platforms.all;
39 };
40}