2022-11-28 21:45:34 +00:00
|
|
|
{ config, pkgs, lib, ... }:
|
2020-06-28 11:36:46 +00:00
|
|
|
|
|
|
|
# This module sets up solr with one core. It is a bit tedious…. If you
|
|
|
|
# know a better solution, please let me know.
|
|
|
|
{
|
2022-11-28 21:45:34 +00:00
|
|
|
nixpkgs.config = {
|
|
|
|
permittedInsecurePackages = [
|
|
|
|
"solr-8.6.3"
|
|
|
|
];
|
|
|
|
};
|
2020-06-28 11:36:46 +00:00
|
|
|
|
|
|
|
services.solr = {
|
|
|
|
enable = true;
|
|
|
|
};
|
|
|
|
# This is needed to run solr script as user solr
|
|
|
|
users.users.solr.useDefaultShell = true;
|
|
|
|
|
|
|
|
systemd.services.solr-init =
|
|
|
|
let
|
|
|
|
solrPort = toString config.services.solr.port;
|
|
|
|
initSolr = ''
|
|
|
|
if [ ! -f ${config.services.solr.stateDir}/docspell_core ]; then
|
2022-11-28 21:45:34 +00:00
|
|
|
while ! echo "" | ${pkgs.inetutils}/bin/telnet localhost ${solrPort}
|
2020-06-28 11:36:46 +00:00
|
|
|
do
|
|
|
|
echo "Waiting for SOLR become ready..."
|
|
|
|
sleep 1.5
|
|
|
|
done
|
|
|
|
${pkgs.su}/bin/su -s ${pkgs.bash}/bin/sh solr -c "${pkgs.solr}/bin/solr create_core -c docspell -p ${solrPort}";
|
|
|
|
touch ${config.services.solr.stateDir}/docspell_core
|
|
|
|
fi
|
|
|
|
'';
|
|
|
|
in
|
2022-11-28 21:45:34 +00:00
|
|
|
{
|
|
|
|
script = initSolr;
|
|
|
|
after = [ "solr.target" ];
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
requires = [ "solr.target" ];
|
|
|
|
description = "Create a core at solr";
|
|
|
|
};
|
2020-06-28 11:36:46 +00:00
|
|
|
|
|
|
|
}
|