From 22f9b7b279417a8b83a3356f5bd3ed3a51b1de82 Mon Sep 17 00:00:00 2001 From: Jussi Kuokkanen Date: Mon, 19 Jun 2023 15:00:23 +0300 Subject: [PATCH 1/5] libvoikko: init at 4.3.2 --- .../libraries/libvoikko/default.nix | 40 +++++++++++++++++++ pkgs/top-level/all-packages.nix | 8 ++++ 2 files changed, 48 insertions(+) create mode 100644 pkgs/development/libraries/libvoikko/default.nix diff --git a/pkgs/development/libraries/libvoikko/default.nix b/pkgs/development/libraries/libvoikko/default.nix new file mode 100644 index 000000000000..3f5f4ef5c858 --- /dev/null +++ b/pkgs/development/libraries/libvoikko/default.nix @@ -0,0 +1,40 @@ +{ stdenv +, lib +, autoreconfHook +, hfst-ospell +, fetchFromGitHub +, pkg-config +, python3 +}: + +stdenv.mkDerivation (finalAttrs: { + pname = "libvoikko"; + version = "4.3.2"; + + src = fetchFromGitHub { + owner = "voikko"; + repo = "corevoikko"; + rev = "refs/tags/rel-libvoikko-${finalAttrs.version}"; + hash = "sha256-0MIQ54dCxyAfdgYWmmTVF+Yfa15K2sjJyP1JNxwHP2M="; + }; + + sourceRoot = "${finalAttrs.src.name}/libvoikko"; + + nativeBuildInputs = [ + autoreconfHook + pkg-config + python3 + ]; + + buildInputs = [ + hfst-ospell + ]; + + meta = with lib; { + homepage = "https://voikko.puimula.org/"; + description = "Finnish language processing library"; + license = licenses.lgpl21Plus; + maintainers = with maintainers; [ lurkki ]; + platforms = platforms.unix; + }; +}) diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 8dc19e94c7fa..1239580d9938 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -41283,4 +41283,12 @@ with pkgs; waylyrics = callPackage ../applications/audio/waylyrics { }; gitrs = callPackage ../tools/misc/gitrs { }; + + libvoikko = callPackage ../development/libraries/libvoikko { }; + + hfst = callPackage ../development/libraries/hfst/hfst.nix { }; + + hfst-ospell = callPackage ../applications/misc/hfst-ospell/default.nix { }; + + omorfi = callPackage ../applications/misc/omorfi/omorfi.nix { }; } From b02e3765e7fcaabc5971af82e51221a065da062b Mon Sep 17 00:00:00 2001 From: Jussi Kuokkanen Date: Mon, 19 Jun 2023 15:18:07 +0300 Subject: [PATCH 2/5] 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 000000000000..3aafd95ba8ab --- /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 000000000000..41707bbd4986 --- /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 000000000000..b865c4c84d63 --- /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 1239580d9938..2871a4a6396b 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 919ef010c48f..17339de0031f 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 { }; From 67424e70c8a9f43140e69ae1852a7841b42e1663 Mon Sep 17 00:00:00 2001 From: Jussi Kuokkanen Date: Mon, 19 Jun 2023 15:24:12 +0300 Subject: [PATCH 3/5] hfst-ospell: init at 0.5.3 --- .../libraries/hfst-ospell/default.nix | 46 +++++++++++++++++++ pkgs/top-level/all-packages.nix | 4 +- 2 files changed, 48 insertions(+), 2 deletions(-) create mode 100644 pkgs/development/libraries/hfst-ospell/default.nix diff --git a/pkgs/development/libraries/hfst-ospell/default.nix b/pkgs/development/libraries/hfst-ospell/default.nix new file mode 100644 index 000000000000..ad07025cc35d --- /dev/null +++ b/pkgs/development/libraries/hfst-ospell/default.nix @@ -0,0 +1,46 @@ +{ lib +, stdenv +, autoreconfHook +, fetchFromGitHub +, icu +, libarchive +, pkg-config +}: + +stdenv.mkDerivation (finalAttrs: { + pname = "hfst-ospell"; + version = "0.5.3"; + + src = fetchFromGitHub { + owner = "hfst"; + repo = "hfst-ospell"; + rev = "refs/tags/v${finalAttrs.version}"; + hash = "sha256-16H1nbAIe+G71+TnlLG0WnH9LktZwmc0d0O+oYduH1k="; + }; + + buildInputs = [ + icu + libarchive + ]; + + nativeBuildInputs = [ + autoreconfHook + pkg-config + ]; + + # libxmlxx is listed as a dependency but Darwin build fails with it, + # might also be better in general since libxmlxx in Nixpkgs is 8 years old + # https://github.com/hfst/hfst-ospell/issues/48#issuecomment-546535653 + configureFlags = [ + "--without-libxmlpp" + "--without-tinyxml2" + ]; + + meta = with lib; { + homepage = "https://github.com/hfst/hfst-ospell/"; + description = "HFST spell checker library and command line tool "; + license = licenses.asl20; + maintainers = with maintainers; [ lurkki ]; + platforms = platforms.unix; + }; +}) diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 2871a4a6396b..f40c9350352e 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -41288,7 +41288,7 @@ with pkgs; hfst = callPackage ../development/libraries/hfst { }; - hfst-ospell = callPackage ../applications/misc/hfst-ospell { }; - omorfi = callPackage ../applications/misc/omorfi { }; + + hfst-ospell = callPackage ../development/libraries/hfst-ospell { }; } From 8d34b31b3179d45e107ec9cca99b0de9585eba76 Mon Sep 17 00:00:00 2001 From: Jussi Kuokkanen Date: Mon, 19 Jun 2023 15:33:16 +0300 Subject: [PATCH 4/5] omorfi: init at 0.9.9 --- .../libraries}/omorfi/default.nix | 48 +++++------- .../python-modules/omorfi/default.nix | 32 ++++++++ .../python-modules/omorfi/importfix.patch | 76 +++++++++++++++++++ pkgs/top-level/all-packages.nix | 10 +-- pkgs/top-level/python-packages.nix | 2 + 5 files changed, 132 insertions(+), 36 deletions(-) rename pkgs/{applications/misc => development/libraries}/omorfi/default.nix (63%) create mode 100644 pkgs/development/python-modules/omorfi/default.nix create mode 100644 pkgs/development/python-modules/omorfi/importfix.patch diff --git a/pkgs/applications/misc/omorfi/default.nix b/pkgs/development/libraries/omorfi/default.nix similarity index 63% rename from pkgs/applications/misc/omorfi/default.nix rename to pkgs/development/libraries/omorfi/default.nix index 3aafd95ba8ab..d6d0f1741d17 100644 --- a/pkgs/applications/misc/omorfi/default.nix +++ b/pkgs/development/libraries/omorfi/default.nix @@ -1,18 +1,15 @@ { lib , stdenv -, autoconf -, automake , autoreconfHook , cg3 , fetchFromGitHub , hfst , hfst-ospell , icu -, libtool , libvoikko +, makeWrapper , pkg-config , python3 -, python3Packages , zip }: @@ -42,30 +39,29 @@ stdenv.mkDerivation (finalAttrs: { python3.pkgs.wrapPython ]; ->>>>>>> 2ea2d99a91e (hfst changes):pkgs/development/libraries/omorfi/default.nix buildInputs = [ - hfst + python3.pkgs.hfst hfst-ospell - python3Packages.hfst-python - icu - ]; - nativeBuildInputs = [ - autoconf - automake - autoreconfHook - cg3 - libtool - pkg-config - python3 libvoikko - zip ]; + + # Supplied pkg-config file doesn't properly expose these propagatedBuildInputs = [ hfst - python3Packages.hfst icu ]; + # Wrap shell scripts so they find the Python scripts + # omorfi.bash inexplicably fails when wrapped + preFixup = '' + wrapPythonProgramsIn "$out/bin" "$out ${python3.pkgs.hfst}" + for i in "$out/bin"/*.{sh,bash}; do + if [ $(basename "$i") != "omorfi.bash" ]; then + wrapProgram "$i" --prefix "PATH" : "$out/bin/" + fi + done + ''; + # Enable all features configureFlags = [ "--enable-labeled-segments" @@ -74,22 +70,12 @@ stdenv.mkDerivation (finalAttrs: { "--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 ]; + # Darwin build fails due to hfst not being found + broken = stdenv.isDarwin; }; }) diff --git a/pkgs/development/python-modules/omorfi/default.nix b/pkgs/development/python-modules/omorfi/default.nix new file mode 100644 index 000000000000..6bbe964de734 --- /dev/null +++ b/pkgs/development/python-modules/omorfi/default.nix @@ -0,0 +1,32 @@ +{ buildPythonPackage +, pkgs +, lib +, stdenv +, hfst +}: + +buildPythonPackage rec { + pname = "omorfi"; + inherit (pkgs.omorfi) src version; + + sourceRoot = "${src.name}/src/python"; + + propagatedBuildInputs = [ + hfst + ]; + + # Fixes some improper import paths + patches = [ ./importfix.patch ]; + + # Apply patch relative to source/src + patchFlags = [ "-p3" ]; + + meta = with lib; { + description = "Python interface for Omorfi"; + homepage = "https://github.com/flammie/omorfi"; + license = licenses.gpl3; + maintainers = with maintainers; [ lurkki ]; + # Ofborg build error (hfst not found?) + broken = stdenv.isDarwin; + }; +} diff --git a/pkgs/development/python-modules/omorfi/importfix.patch b/pkgs/development/python-modules/omorfi/importfix.patch new file mode 100644 index 000000000000..67a54363c7b1 --- /dev/null +++ b/pkgs/development/python-modules/omorfi/importfix.patch @@ -0,0 +1,76 @@ +diff --git a/src/python/omorfi/entryguessing/gradation.py b/src/python/omorfi/entryguessing/gradation.py +index 7d3ed8cb..825d7ead 100755 +--- a/src/python/omorfi/entryguessing/gradation.py ++++ b/src/python/omorfi/entryguessing/gradation.py +@@ -17,8 +17,8 @@ + # You should have received a copy of the GNU General Public License + # along with this program. If not, see . + +-from .omorfi.error_logging import fail_guess_because +-from .omorfi.string_mangling import replace_rightmost, replace_rightmosts ++from omorfi.error_logging import fail_guess_because ++from omorfi.string_manglers import replace_rightmost, replace_rightmosts + + + def gradation_make_morphophonemes(wordmap): +diff --git a/src/python/omorfi/entryguessing/guess_new_class.py b/src/python/omorfi/entryguessing/guess_new_class.py +index 1884716b..3a781bfc 100755 +--- a/src/python/omorfi/entryguessing/guess_new_class.py ++++ b/src/python/omorfi/entryguessing/guess_new_class.py +@@ -17,8 +17,8 @@ + # You should have received a copy of the GNU General Public License + # along with this program. If not, see . + +-from .error_logging import fail_guess_because +-from .string_manglers import three_syllable ++from omorfi.error_logging import fail_guess_because ++from omorfi.string_manglers import three_syllable + + + def guess_new_class(wordmap): +diff --git a/src/python/omorfi/entryguessing/plurale_tantum.py b/src/python/omorfi/entryguessing/plurale_tantum.py +index a8af81fb..95fc4b7b 100755 +--- a/src/python/omorfi/entryguessing/plurale_tantum.py ++++ b/src/python/omorfi/entryguessing/plurale_tantum.py +@@ -17,8 +17,8 @@ + # You should have received a copy of the GNU General Public License + # along with this program. If not, see . + +-from .error_logging import fail_guess_because +-from .omorfi.string_manglers import replace_rightmost, replace_rightmosts ++from omorfi.error_logging import fail_guess_because ++from omorfi.string_manglers import replace_rightmost, replace_rightmosts + + + def plurale_tantum_get_singular_stem(wordmap): +diff --git a/src/python/omorfi/formats/experimental_xml_formatter.py b/src/python/omorfi/formats/experimental_xml_formatter.py +index abccbff5..11b0f518 100755 +--- a/src/python/omorfi/formats/experimental_xml_formatter.py ++++ b/src/python/omorfi/formats/experimental_xml_formatter.py +@@ -19,9 +19,9 @@ + + from xml.sax.saxutils import escape as xml_escape + +-from ftb3_formatter import Ftb3Formatter ++from .ftb3_formatter import Ftb3Formatter + +-from .settings import version_id_easter_egg ++from omorfi.settings import version_id_easter_egg + + + def make_xmlid(s): +diff --git a/src/python/omorfi/formats/lexc_formatter.py b/src/python/omorfi/formats/lexc_formatter.py +index 4ec616b7..b146129f 100755 +--- a/src/python/omorfi/formats/lexc_formatter.py ++++ b/src/python/omorfi/formats/lexc_formatter.py +@@ -19,8 +19,8 @@ + + # functions for formatting the database data to lexc + +-from .settings import deriv_boundary, morph_boundary, newword_boundary, optional_hyphen, stub_boundary, word_boundary +-from .string_manglers import lexc_escape ++from omorfi.settings import deriv_boundary, morph_boundary, newword_boundary, optional_hyphen, stub_boundary, word_boundary ++from omorfi.string_manglers import lexc_escape + + + def format_copyright_lexc(): diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index f40c9350352e..53e82aa5d12c 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -41280,15 +41280,15 @@ with pkgs; charasay = callPackage ../tools/misc/charasay { }; - waylyrics = callPackage ../applications/audio/waylyrics { }; - - gitrs = callPackage ../tools/misc/gitrs { }; - libvoikko = callPackage ../development/libraries/libvoikko { }; hfst = callPackage ../development/libraries/hfst { }; - omorfi = callPackage ../applications/misc/omorfi { }; + omorfi = callPackage ../development/libraries/omorfi { }; hfst-ospell = callPackage ../development/libraries/hfst-ospell { }; + + waylyrics = callPackage ../applications/audio/waylyrics { }; + + gitrs = callPackage ../tools/misc/gitrs { }; } diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index 17339de0031f..0ec5788a2125 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -7155,6 +7155,8 @@ self: super: with self; { omnilogic = callPackage ../development/python-modules/omnilogic { }; + omorfi = callPackage ../development/python-modules/omorfi { }; + omrdatasettools = callPackage ../development/python-modules/omrdatasettools { }; ondilo = callPackage ../development/python-modules/ondilo { }; From a7e43128154c5d6854e8c4f6ec67ce60add94432 Mon Sep 17 00:00:00 2001 From: Jussi Kuokkanen Date: Tue, 20 Jun 2023 18:35:29 +0300 Subject: [PATCH 5/5] maintainers: add lurkki --- maintainers/maintainer-list.nix | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/maintainers/maintainer-list.nix b/maintainers/maintainer-list.nix index b8ad4e9724cb..395a7b205860 100644 --- a/maintainers/maintainer-list.nix +++ b/maintainers/maintainer-list.nix @@ -9799,6 +9799,12 @@ githubId = 782440; name = "Luna Nova"; }; + lurkki = { + email = "jussi.kuokkanen@protonmail.com"; + github = "Lurkki14"; + githubId = 44469719; + name = "Jussi Kuokkanen"; + }; lux = { email = "lux@lux.name"; github = "luxzeitlos";