Merge pull request #262224 from chayleaf/tsja

postgresqlPackages.tsja: init at 0.5.0
This commit is contained in:
Peder Bergebakken Sundt 2023-10-27 19:53:14 +02:00 committed by GitHub
commit fb1c60b65a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 82 additions and 1 deletions

View file

@ -849,6 +849,7 @@ in {
trezord = handleTest ./trezord.nix {};
trickster = handleTest ./trickster.nix {};
trilium-server = handleTestOn ["x86_64-linux"] ./trilium-server.nix {};
tsja = handleTest ./tsja.nix {};
tsm-client-gui = handleTest ./tsm-client-gui.nix {};
txredisapi = handleTest ./txredisapi.nix {};
tuptime = handleTest ./tuptime.nix {};

32
nixos/tests/tsja.nix Normal file
View file

@ -0,0 +1,32 @@
import ./make-test-python.nix ({ pkgs, lib, ...} : {
name = "tsja";
meta = {
maintainers = with lib.maintainers; [ chayleaf ];
};
nodes = {
master =
{ config, ... }:
{
services.postgresql = {
enable = true;
extraPlugins = with config.services.postgresql.package.pkgs; [
tsja
];
};
};
};
testScript = ''
start_all()
master.wait_for_unit("postgresql")
master.succeed("sudo -u postgres psql -f /run/current-system/sw/share/postgresql/extension/libtsja_dbinit.sql")
# make sure "日本語" is parsed as a separate lexeme
master.succeed("""
sudo -u postgres \\
psql -c "SELECT * FROM ts_debug('japanese', 'PostgreSQL')" \\
| grep "{}"
""")
'';
})

View file

@ -0,0 +1,45 @@
{ lib
, fetchzip
, nixosTests
, stdenv
, mecab
, postgresql
}:
stdenv.mkDerivation rec {
pname = "tsja";
version = "0.5.0";
src = fetchzip {
url = "https://www.amris.jp/tsja/tsja-${version}.tar.xz";
hash = "sha256-h59UhUG/7biN8NaDiGK6kXDqfhR9uMzt8CpwbJ+PpEM=";
};
postPatch = ''
substituteInPlace Makefile \
--replace /usr/local/pgsql ${postgresql} \
--replace -L/usr/local/lib "" \
--replace -I/usr/local/include ""
substituteInPlace tsja.c --replace /usr/local/lib/mecab ${mecab}/lib/mecab
'';
buildInputs = [ mecab postgresql ];
installPhase = ''
mkdir -p $out/lib $out/share/postgresql/extension
mv libtsja.so $out/lib
mv dbinit_libtsja.txt $out/share/postgresql/extension/libtsja_dbinit.sql
'';
passthru.tests.tsja = nixosTests.tsja;
meta = with lib; {
description = "PostgreSQL extension implementing Japanese text search";
homepage = "https://www.amris.jp/tsja/index.html";
maintainers = with maintainers; [ chayleaf ];
# GNU-specific linker options are used
platforms = platforms.gnu;
license = licenses.gpl2Only;
};
}

View file

@ -87,5 +87,7 @@ self: super: {
rum = super.callPackage ./ext/rum.nix { };
tsja = super.callPackage ./ext/tsja.nix { };
wal2json = super.callPackage ./ext/wal2json.nix { };
}

View file

@ -7,7 +7,8 @@ stdenv.mkDerivation (finalAttrs: ((mecab-base finalAttrs) // {
pname = "mecab";
postInstall = ''
sed -i 's|^dicdir = .*$|dicdir = ${mecab-ipadic}|' "$out/etc/mecabrc"
mkdir -p $out/lib/mecab/dic
ln -s ${mecab-ipadic} $out/lib/mecab/dic/ipadic
'';
meta = with lib; {