[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.
CoreNLP can be started with nix:
```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:
```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
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
(if builtins.elem builtins.currentSystem [ "x86_64-darwin" "aarch64-darwin" ]
then ./pinned-25.05.darwin.nix
else ./pinned-25.05.nix) {} }:
else ./pinned-25.05.nix)
{ }
}:
rec {
inherit pkgs;
ghc966 = pkgs.haskell.compiler.ghc966;
cabal_install = pkgs.haskell.lib.compose.justStaticExecutables pkgs.haskell.packages.ghc966.cabal-install;
graphviz = pkgs.callPackage ./graphviz.nix {};
igraph_0_10_4 = pkgs.callPackage ./igraph.nix {};
corenlp = pkgs.callPackage ./corenlp.nix { }; # 4.5.8
graphviz = pkgs.callPackage ./graphviz.nix { };
igraph_0_10_4 = pkgs.callPackage ./igraph.nix { };
cabal2stack = pkgs.callPackage ./cabal2stack.nix { ghc = ghc966; };
nng_notls = pkgs.nng.overrideAttrs (old: {
cmakeFlags = (old.cmakeFlags or []) ++ [ "-DNNG_ENABLE_TLS=OFF" ];
cmakeFlags = (old.cmakeFlags or [ ]) ++ [ "-DNNG_ENABLE_TLS=OFF" ];
});
hsBuildInputs = [
......@@ -28,7 +30,6 @@ rec {
blas
bzip2
cabal2stack
corenlp
curl
czmq
docker-compose
......@@ -56,7 +57,7 @@ rec {
zlib
zeromq
curl
] ++ ( lib.optionals stdenv.isDarwin [
] ++ (lib.optionals stdenv.isDarwin [
darwin.apple_sdk.frameworks.Accelerate
]);
libPaths = pkgs.lib.makeLibraryPath nonhsBuildInputs;
......
......@@ -21,7 +21,10 @@ startCoreNLPServer :: IO ProcessHandle
startCoreNLPServer = do
putText "calling start core nlp"
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
-- NOTE(adn) Issue #451, this one has to stay disabled, because if we
-- turn it on, despite the confusing documentation on the `process` library
......@@ -35,7 +38,7 @@ startCoreNLPServer = do
, std_err = UseHandle devNull
}) `catch` \e -> case e of
_ | 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
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