2014-04-14 16:26:48 +02:00
|
|
|
{ config, lib, pkgs, ... }:
|
2014-03-13 00:32:34 +01:00
|
|
|
|
2014-04-14 16:26:48 +02:00
|
|
|
with lib;
|
2014-03-13 00:32:34 +01:00
|
|
|
|
|
|
|
let
|
|
|
|
|
|
|
|
cfg = config.services.solr;
|
|
|
|
|
2014-03-21 12:02:35 +01:00
|
|
|
# Assemble all jars needed for solr
|
|
|
|
solrJars = pkgs.stdenv.mkDerivation {
|
|
|
|
name = "solr-jars";
|
|
|
|
|
|
|
|
src = pkgs.fetchurl {
|
|
|
|
url = http://archive.apache.org/dist/tomcat/tomcat-5/v5.5.36/bin/apache-tomcat-5.5.36.tar.gz;
|
|
|
|
sha256 = "01mzvh53wrs1p2ym765jwd00gl6kn8f9k3nhdrnhdqr8dhimfb2p";
|
|
|
|
};
|
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
mkdir -p $out/lib
|
|
|
|
cp common/lib/*.jar $out/lib/
|
|
|
|
ln -s ${pkgs.ant}/lib/ant/lib/ant.jar $out/lib/
|
|
|
|
ln -s ${cfg.solrPackage}/lib/ext/* $out/lib/
|
2015-01-02 00:49:20 +01:00
|
|
|
ln -s ${pkgs.jdk.home}/lib/tools.jar $out/lib/
|
2014-04-03 22:46:45 +02:00
|
|
|
'' + optionalString (cfg.extraJars != []) ''
|
|
|
|
for f in ${concatStringsSep " " cfg.extraJars}; do
|
|
|
|
cp $f $out/lib
|
|
|
|
done
|
2014-03-21 12:02:35 +01:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2014-03-13 00:32:34 +01:00
|
|
|
in {
|
|
|
|
|
|
|
|
options = {
|
|
|
|
services.solr = {
|
|
|
|
enable = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = false;
|
|
|
|
description = ''
|
|
|
|
Enables the solr service.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
javaPackage = mkOption {
|
|
|
|
type = types.package;
|
2015-01-07 20:20:46 +01:00
|
|
|
default = pkgs.jre;
|
2016-01-17 19:34:55 +01:00
|
|
|
defaultText = "pkgs.jre";
|
2014-03-13 00:32:34 +01:00
|
|
|
description = ''
|
|
|
|
Which Java derivation to use for running solr.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
solrPackage = mkOption {
|
|
|
|
type = types.package;
|
|
|
|
default = pkgs.solr;
|
2016-01-17 19:34:55 +01:00
|
|
|
defaultText = "pkgs.solr";
|
2014-03-13 00:32:34 +01:00
|
|
|
description = ''
|
|
|
|
Which solr derivation to use for running solr.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2014-04-03 22:46:45 +02:00
|
|
|
extraJars = mkOption {
|
|
|
|
type = types.listOf types.path;
|
|
|
|
default = [];
|
|
|
|
description = ''
|
|
|
|
List of paths pointing to jars. Jars are copied to commonLibFolder to be available to java/solr.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2014-03-13 00:32:34 +01:00
|
|
|
log4jConfiguration = mkOption {
|
|
|
|
type = types.lines;
|
|
|
|
default = ''
|
|
|
|
log4j.rootLogger=INFO, stdout
|
|
|
|
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
|
|
|
|
log4j.appender.stdout.Target=System.out
|
|
|
|
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
|
|
|
|
log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n
|
|
|
|
'';
|
|
|
|
description = ''
|
|
|
|
Contents of the <literal>log4j.properties</literal> used. By default,
|
|
|
|
everything is logged to stdout (picked up by systemd) with level INFO.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
user = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
description = ''
|
|
|
|
The user that should run the solr process and.
|
|
|
|
the working directories.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
group = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
description = ''
|
|
|
|
The group that will own the working directory.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
solrHome = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
description = ''
|
|
|
|
The solr home directory. It is your own responsibility to
|
|
|
|
make sure this directory contains a working solr configuration,
|
|
|
|
and is writeable by the the user running the solr service.
|
|
|
|
Failing to do so, the solr will not start properly.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
extraJavaOptions = mkOption {
|
|
|
|
type = types.listOf types.str;
|
|
|
|
default = [];
|
|
|
|
description = ''
|
|
|
|
Extra command line options given to the java process running
|
|
|
|
solr.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
extraWinstoneOptions = mkOption {
|
|
|
|
type = types.listOf types.str;
|
|
|
|
default = [];
|
|
|
|
description = ''
|
|
|
|
Extra command line options given to the Winstone, which is
|
|
|
|
the servlet container hosting solr.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
|
|
|
|
services.winstone.solr = {
|
|
|
|
serviceName = "solr";
|
|
|
|
inherit (cfg) user group javaPackage;
|
|
|
|
warFile = "${cfg.solrPackage}/lib/solr.war";
|
|
|
|
extraOptions = [
|
2014-03-21 12:02:35 +01:00
|
|
|
"--commonLibFolder=${solrJars}/lib"
|
|
|
|
"--useJasper"
|
2014-03-13 00:32:34 +01:00
|
|
|
] ++ cfg.extraWinstoneOptions;
|
|
|
|
extraJavaOptions = [
|
|
|
|
"-Dsolr.solr.home=${cfg.solrHome}"
|
|
|
|
"-Dlog4j.configuration=file://${pkgs.writeText "log4j.properties" cfg.log4jConfiguration}"
|
|
|
|
] ++ cfg.extraJavaOptions;
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|