From 6416e62afef6fa8e31b3482d905527c79d42a927 Mon Sep 17 00:00:00 2001 From: outfoxxed Date: Thu, 24 Apr 2025 20:46:34 -0700 Subject: [PATCH] pending --- cpu.nix | 9 +++---- flake.nix | 19 +++++++++++--- pystemmer.nix | 69 +++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 88 insertions(+), 9 deletions(-) create mode 100644 pystemmer.nix diff --git a/cpu.nix b/cpu.nix index cbfcdfb..649f7c0 100644 --- a/cpu.nix +++ b/cpu.nix @@ -9,10 +9,9 @@ nixpkgs.buildPlatform.system = "x86_64-linux"; - nixpkgs.config.hostSystem = let - arch = "rv64imafdcv_zicbom_zicbob_zicboz_zicntr_zicond_zicsr_zifencei_zihintpause_zihpm_zfh_zfhmin_zkt_zba_zbb_zbc_zbs_zbkc_zvfh_zvfhmin_zvkt"; - in { - gcc.arch = arch; - system = "riscv64-unknown-linux-lp64d"; + nixpkgs.hostPlatform = { + gcc.arch = "rv64imafdcv_zicbom_zicbop_zicboz_zicntr_zicond_zicsr_zifencei_zihintpause_zihpm_zfh_zfhmin_zkt_zba_zbb_zbc_zbs_zbkc_zvfh_zvfhmin_zvkt"; + gcc.abi = "lp64d"; + system = "riscv64-unknown-linux-gnu"; }; } diff --git a/flake.nix b/flake.nix index 29d5ce3..86c3c9d 100644 --- a/flake.nix +++ b/flake.nix @@ -19,8 +19,18 @@ ./system.nix ./boot.nix - ./ghc.nix - ./riscvfixes.nix + #./ghc.nix + #./riscvfixes.nix + + { + nixpkgs.overlays = [(final: prev: { + pythonPackagesExtensions = prev.pythonPackagesExtensions ++ [ + (pyfinal: pyprev: { + pystemmer = pyfinal.callPackage ./pystemmer.nix {}; + }) + ]; + })]; + } ]; }; }; @@ -29,9 +39,10 @@ x86_64-linux = let pkgs = nixpkgs.legacyPackages.x86_64-linux; in { - boot = pkgs.linkFarm "boot" { + pystemmer = pkgs.python312Packages.pystemmer; + /*boot = pkgs.linkFarm "boot" { "ghc-9.4.8" = pkgs.pkgsCross.riscv64.haskell.compiler.native-bignum.ghc948; - }; + };*/ }; }; }; diff --git a/pystemmer.nix b/pystemmer.nix new file mode 100644 index 0000000..9c9de52 --- /dev/null +++ b/pystemmer.nix @@ -0,0 +1,69 @@ +{ + lib, + python, + fetchFromGitHub, + fetchpatch2, + buildPythonPackage, + cython, + setuptools, + pkgsHostHost, + buildPackages, + pkgsCross, + pkgs, + libstemmer, +}: let + #inherit (targetPackages) libstemmer; + #libstemmer = builtins.trace "${pkgsHostHost.libstemmer} ${buildPackages.libstemmer} ${pkgs.libstemmer}" pkgsHostHost.libstemmer;#targetPackages.libstemmer; +in buildPythonPackage rec { + pname = "pystemmer"; + version = "2.2.0.1-fix"; + + src = fetchFromGitHub { + owner = "snowballstem"; + repo = "pystemmer"; + tag = "v${version}"; + hash = "sha256-ngPx95ybgJmndpNPBwCa3BCNsozRg+dlEw+nhlIwI58="; + }; + + patches = [ + (fetchpatch2 { + # relax cython constraint + name = "pystemmer-relax-cython.patch"; + url = "https://github.com/snowballstem/pystemmer/commit/d3d423dc877b4f49e0ab1776f7edaff37feb6799.patch"; + hash = "sha256-9K6gy/cLFPfW82XYHVVPXUbQhf8XyB4NUi4YqNtyWcw="; + }) + ]; + + build-system = [ + cython + setuptools + ]; + + postConfigure = let a = '' + export PYSTEMMER_SYSTEM_LIBSTEMMER="${lib.getDev libstemmer}/include" + echo $PYSTEMMER_SYSTEM_LIBSTEMMER + ''; in builtins.trace a a; + + env.NIX_CFLAGS_COMPILE = toString [ "-I${lib.getDev libstemmer}/include" ]; + + NIX_CFLAGS_LINK = [ "-L${libstemmer}/lib" ]; + + pythonImportsCheck = [ "Stemmer" ]; + + checkPhase = '' + runHook preCheck + ${python.interpreter} runtests.py + runHook postCheck + ''; + + meta = with lib; { + description = "Snowball stemming algorithms, for information retrieval"; + downloadPage = "https://github.com/snowballstem/pystemmer"; + homepage = "http://snowball.tartarus.org/"; + license = with licenses; [ + bsd3 + mit + ]; + platforms = platforms.unix; + }; +}