[nix] move corenlp to separate flake in core-nix repo

#483
parent 397b19a5
Pipeline #7720 canceled with stages
in 27 minutes and 57 seconds
...@@ -117,15 +117,17 @@ And provide a name and a password for the master user as requested. ...@@ -117,15 +117,17 @@ And provide a name and a password for the master user as requested.
CoreNLP can be started with nix: CoreNLP can be started with nix:
```shell ```shell
nix-shell --run startCoreNLPServer.sh nix run "git+https://gitlab.iscpif.fr/gargantext/corenlp-nix.git"#
``` ```
By default, this starts on port `9000`. If you want a different port, then do: By default, this starts on port `9000`. If you want a different port, then do:
```shell ```shell
nix-shell --run 'startCoreNLPServer.sh -p 9001' nix run "git+https://gitlab.iscpif.fr/gargantext/corenlp-nix.git"# -- -p 9001
``` ```
See https://gitlab.iscpif.fr/gargantext/corenlp-nix for more info.
### Running Gargantext ### Running Gargantext
From inside the `haskell-gargantext/` directory, run From inside the `haskell-gargantext/` directory, run
......
# https://nixos.wiki/wiki/Java
{ fetchzip,
makeWrapper,
stdenv,
writeShellScript,
jre,
version ? "4.5.9",
hash ? "sha256-DOGBkGJfvR1PoXz2CNoo58HXwGLxvPKMChRqlrFtQLQ=",
}:
stdenv.mkDerivation (finalAttrs:
let
startServer = writeShellScript "startCoreNLPServer.sh" ''
set -x
PORT=9000
while getopts ':p:h' opt; do
case $opt in
(p) PORT=$OPTARG;;
(h) echo "$(basename $0) [-p 9000]"
exit 0
;;
esac
done
shift "$((OPTIND - 1))"
${jre}/bin/java -mx4g -cp "$CORENLP_PATH/*" edu.stanford.nlp.pipeline.StanfordCoreNLPServer -port $PORT -timeout 15000 "$@"
'';
# see https://huggingface.co/stanfordnlp/CoreNLP/commits/main
versionCommits = {
"4.5.8" = "34264e88b7add9e0045f4727bc7d1872385f06aa";
"4.5.9" = "06f79ee8b1ec475d7630b1871bfd75a57c77ffa4";
};
commit = versionCommits."${finalAttrs.version}";
in
{
name = "corenlp";
inherit version;
src = fetchzip {
inherit hash;
# url = "http://nlp.stanford.edu/software/stanford-corenlp-${finalAttrs.version}.zip";
# huggin face is more stable
url = "https://huggingface.co/stanfordnlp/CoreNLP/resolve/${commit}/stanford-corenlp-latest.zip";
};
buildInputs = [
jre
];
nativeBuildInputs = [
makeWrapper
];
phases = [ "unpackPhase" "installPhase" ];
installPhase = ''
runHook preInstall
mkdir -p $out/bin
mkdir -p $out/share/corenlp
cp -r . $out/share/corenlp
makeWrapper ${startServer} $out/bin/startCoreNLPServer.sh \
--set CORENLP_PATH "$out/share/corenlp"
runHook postInstall
'';
}
)
{ pkgs ? import (if builtins.elem builtins.currentSystem ["x86_64-darwin" "aarch64-darwin"] { pkgs ? import
then ./pinned-25.05.darwin.nix (if builtins.elem builtins.currentSystem [ "x86_64-darwin" "aarch64-darwin" ]
else ./pinned-25.05.nix) {} }: then ./pinned-25.05.darwin.nix
else ./pinned-25.05.nix)
{ }
}:
rec { rec {
inherit pkgs; inherit pkgs;
ghc966 = pkgs.haskell.compiler.ghc966; ghc966 = pkgs.haskell.compiler.ghc966;
cabal_install = pkgs.haskell.lib.compose.justStaticExecutables pkgs.haskell.packages.ghc966.cabal-install; cabal_install = pkgs.haskell.lib.compose.justStaticExecutables pkgs.haskell.packages.ghc966.cabal-install;
graphviz = pkgs.callPackage ./graphviz.nix {}; graphviz = pkgs.callPackage ./graphviz.nix { };
igraph_0_10_4 = pkgs.callPackage ./igraph.nix {}; igraph_0_10_4 = pkgs.callPackage ./igraph.nix { };
corenlp = pkgs.callPackage ./corenlp.nix { }; # 4.5.8
cabal2stack = pkgs.callPackage ./cabal2stack.nix { ghc = ghc966; }; cabal2stack = pkgs.callPackage ./cabal2stack.nix { ghc = ghc966; };
nng_notls = pkgs.nng.overrideAttrs (old: { nng_notls = pkgs.nng.overrideAttrs (old: {
cmakeFlags = (old.cmakeFlags or []) ++ [ "-DNNG_ENABLE_TLS=OFF" ]; cmakeFlags = (old.cmakeFlags or [ ]) ++ [ "-DNNG_ENABLE_TLS=OFF" ];
}); });
hsBuildInputs = [ hsBuildInputs = [
ghc966 ghc966
cabal_install cabal_install
...@@ -28,7 +30,6 @@ rec { ...@@ -28,7 +30,6 @@ rec {
blas blas
bzip2 bzip2
cabal2stack cabal2stack
corenlp
curl curl
czmq czmq
docker-compose docker-compose
...@@ -47,7 +48,7 @@ rec { ...@@ -47,7 +48,7 @@ rec {
libpqxx libpqxx
libsodium libsodium
nng_notls nng_notls
nil # nix language server nil # nix language server
pcre pcre
pkg-config pkg-config
postgresql postgresql
...@@ -56,9 +57,9 @@ rec { ...@@ -56,9 +57,9 @@ rec {
zlib zlib
zeromq zeromq
curl curl
] ++ ( lib.optionals stdenv.isDarwin [ ] ++ (lib.optionals stdenv.isDarwin [
darwin.apple_sdk.frameworks.Accelerate darwin.apple_sdk.frameworks.Accelerate
]); ]);
libPaths = pkgs.lib.makeLibraryPath nonhsBuildInputs; libPaths = pkgs.lib.makeLibraryPath nonhsBuildInputs;
shellHook = '' shellHook = ''
export LD_LIBRARY_PATH="${pkgs.gfortran.cc.lib}:${libPaths}:$LD_LIBRARY_PATH" export LD_LIBRARY_PATH="${pkgs.gfortran.cc.lib}:${libPaths}:$LD_LIBRARY_PATH"
......
...@@ -21,7 +21,10 @@ startCoreNLPServer :: IO ProcessHandle ...@@ -21,7 +21,10 @@ startCoreNLPServer :: IO ProcessHandle
startCoreNLPServer = do startCoreNLPServer = do
putText "calling start core nlp" putText "calling start core nlp"
devNull <- openFile "/dev/null" WriteMode devNull <- openFile "/dev/null" WriteMode
let p = proc "startCoreNLPServer.sh" [] let p = proc "nix" [ "--extra-experimental-features"
, "nix-command flakes"
, "run"
, "git+https://gitlab.iscpif.fr/gargantext/corenlp-nix.git" ]
(_, _, _, hdl) <- (createProcess $ p { cwd = Nothing (_, _, _, hdl) <- (createProcess $ p { cwd = Nothing
-- NOTE(adn) Issue #451, this one has to stay disabled, because if we -- NOTE(adn) Issue #451, this one has to stay disabled, because if we
-- turn it on, despite the confusing documentation on the `process` library -- turn it on, despite the confusing documentation on the `process` library
...@@ -35,7 +38,7 @@ startCoreNLPServer = do ...@@ -35,7 +38,7 @@ startCoreNLPServer = do
, std_err = UseHandle devNull , std_err = UseHandle devNull
}) `catch` \e -> case e of }) `catch` \e -> case e of
_ | True <- "does not exist" `isInfixOf` (T.pack . show @SomeException $ e) _ | True <- "does not exist" `isInfixOf` (T.pack . show @SomeException $ e)
-> fail $ "Cannot execute the 'startCoreNLPServer.sh' script. Make sure you are in a nix environment." -> fail $ "Cannot execute the 'corenlp' via nix flakes. Make sure you are in a nix environment."
| otherwise -> throwIO e | otherwise -> throwIO e
pure hdl pure hdl
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment