From b02e3765e7fcaabc5971af82e51221a065da062b Mon Sep 17 00:00:00 2001 From: Jussi Kuokkanen Date: Mon, 19 Jun 2023 15:18:07 +0300 Subject: [PATCH] hfst: init at 3.16.0 --- pkgs/applications/misc/omorfi/default.nix | 95 +++++++++++++++++++ pkgs/development/libraries/hfst/default.nix | 53 +++++++++++ .../python-modules/hfst/default.nix | 45 +++++++++ pkgs/top-level/all-packages.nix | 6 +- pkgs/top-level/python-packages.nix | 2 + 5 files changed, 198 insertions(+), 3 deletions(-) create mode 100644 pkgs/applications/misc/omorfi/default.nix create mode 100644 pkgs/development/libraries/hfst/default.nix create mode 100644 pkgs/development/python-modules/hfst/default.nix diff --git a/pkgs/applications/misc/omorfi/default.nix b/pkgs/applications/misc/omorfi/default.nix new file mode 100644 index 00000000000..3aafd95ba8a --- /dev/null +++ b/pkgs/applications/misc/omorfi/default.nix @@ -0,0 +1,95 @@ +{ lib +, stdenv +, autoconf +, automake +, autoreconfHook +, cg3 +, fetchFromGitHub +, hfst +, hfst-ospell +, icu +, libtool +, libvoikko +, pkg-config +, python3 +, python3Packages +, zip +}: + +stdenv.mkDerivation (finalAttrs: { + pname = "omorfi"; + version = "0.9.9"; + + src = fetchFromGitHub { + owner = "flammie"; + repo = "omorfi"; + rev = "refs/tags/v${finalAttrs.version}"; + hash = "sha256-UoqdwNWCNOPX6u1YBlnXUcB/fmcvcy/HXbYciVrMBOY="; + }; + + # Fix for omorfi-hyphenate.sh file not found error + postInstall = '' + ln -s $out/share/omorfi/{omorfi.hyphenate-rules.hfst,omorfi.hyphenate.hfst} + ''; + + nativeBuildInputs = [ + autoreconfHook + cg3 + makeWrapper + pkg-config + python3 + zip + python3.pkgs.wrapPython + ]; + +>>>>>>> 2ea2d99a91e (hfst changes):pkgs/development/libraries/omorfi/default.nix + buildInputs = [ + hfst + hfst-ospell + python3Packages.hfst-python + icu + ]; + nativeBuildInputs = [ + autoconf + automake + autoreconfHook + cg3 + libtool + pkg-config + python3 + libvoikko + zip + ]; + propagatedBuildInputs = [ + hfst + python3Packages.hfst + icu + ]; + + # Enable all features + configureFlags = [ + "--enable-labeled-segments" + "--enable-lemmatiser" + "--enable-segmenter" + "--enable-hyphenator" + ]; + + # Fix for omorfi-hyphenate.sh file not found error + postInstall = '' + mv $out/share/omorfi/omorfi.hyphenate-rules.hfst $out/share/omorfi/omorfi.hyphenate.hfst + ''; + + src = fetchFromGitHub { + owner = "flammie"; + repo = "omorfi"; + rev = "refs/tags/v${version}"; + hash = "sha256-UoqdwNWCNOPX6u1YBlnXUcB/fmcvcy/HXbYciVrMBOY="; + }; + + meta = with lib; { + description = "Analysis for Finnish text"; + homepage = "https://github.com/flammie/omorfi"; + license = licenses.gpl3; + maintainers = with maintainers; [ lurkki ]; + }; +}) diff --git a/pkgs/development/libraries/hfst/default.nix b/pkgs/development/libraries/hfst/default.nix new file mode 100644 index 00000000000..41707bbd498 --- /dev/null +++ b/pkgs/development/libraries/hfst/default.nix @@ -0,0 +1,53 @@ +{ lib +, autoreconfHook +, bison +, flex +, foma +, fetchFromGitHub +, gettext +, icu +, stdenv +, swig +, pkg-config +, zlib +}: + +stdenv.mkDerivation (finalAttrs: { + pname = "hfst"; + version = "3.16.0"; + + src = fetchFromGitHub { + owner = "hfst"; + repo = "hfst"; + rev = "refs/tags/v${finalAttrs.version}"; + hash = "sha256-2ST0s08Pcp+hTn7rUTgPE1QkH6PPWtiuFezXV3QW0kU="; + }; + + nativeBuildInputs = [ + autoreconfHook + bison + flex + pkg-config + swig + ]; + + buildInputs = [ + foma + gettext + icu + zlib + ]; + + configureFlags = [ + "--enable-all-tools" + "--with-foma-upstream=true" + ]; + + meta = with lib; { + description = "FST language processing library"; + homepage = "https://github.com/hfst/hfst"; + license = licenses.gpl3Plus; + maintainers = with maintainers; [ lurkki ]; + platforms = platforms.unix; + }; +}) diff --git a/pkgs/development/python-modules/hfst/default.nix b/pkgs/development/python-modules/hfst/default.nix new file mode 100644 index 00000000000..b865c4c84d6 --- /dev/null +++ b/pkgs/development/python-modules/hfst/default.nix @@ -0,0 +1,45 @@ +{ lib +, pkgs +, stdenv +, buildPythonPackage +, foma +, icu +, swig +}: + +buildPythonPackage rec { + pname = "hfst"; + inherit (pkgs.hfst) version src; + + sourceRoot = "${src.name}/python"; + + postPatch = '' + # omorfi-python looks for 'hfst' Python package + sed -i 's/libhfst_swig/hfst/' setup.py; + ''; + + nativeBuildInputs = [ + swig + ]; + + buildInputs = [ + icu + pkgs.hfst + ]; + + setupPyBuildFlags = [ + "--inplace" + ]; + + # Find foma in Darwin tests + preCheck = lib.optionalString stdenv.isDarwin '' + export DYLD_LIBRARY_PATH="${foma}/lib" + ''; + + meta = with lib; { + description = "Python bindings for HFST"; + homepage = "https://github.com/hfst/hfst"; + license = licenses.gpl3; + maintainers = with maintainers; [ lurkki ]; + }; +} diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 1239580d993..2871a4a6396 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -41286,9 +41286,9 @@ with pkgs; libvoikko = callPackage ../development/libraries/libvoikko { }; - hfst = callPackage ../development/libraries/hfst/hfst.nix { }; + hfst = callPackage ../development/libraries/hfst { }; - hfst-ospell = callPackage ../applications/misc/hfst-ospell/default.nix { }; + hfst-ospell = callPackage ../applications/misc/hfst-ospell { }; - omorfi = callPackage ../applications/misc/omorfi/omorfi.nix { }; + omorfi = callPackage ../applications/misc/omorfi { }; } diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index 919ef010c48..17339de0031 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -4636,6 +4636,8 @@ self: super: with self; { hexdump = callPackage ../development/python-modules/hexdump { }; + hfst = callPackage ../development/python-modules/hfst { }; + hg-commitsigs = callPackage ../development/python-modules/hg-commitsigs { }; hg-evolve = callPackage ../development/python-modules/hg-evolve { };