1 { config, lib, pkgs, ... }:
7 cfg = config.services.solr;
14 enable = mkEnableOption (lib.mdDoc "Solr");
19 defaultText = literalExpression "pkgs.solr";
20 description = lib.mdDoc "Which Solr package to use.";
26 description = lib.mdDoc "Port on which Solr is ran.";
31 default = "/var/lib/solr";
32 description = lib.mdDoc "The solr home directory containing config, data, and logging files.";
35 extraJavaOptions = mkOption {
36 type = types.listOf types.str;
38 description = lib.mdDoc "Extra command line options given to the java process running Solr.";
44 description = lib.mdDoc "User under which Solr is ran.";
50 description = lib.mdDoc "Group under which Solr is ran.";
55 config = mkIf cfg.enable {
57 environment.systemPackages = [ cfg.package ];
59 systemd.services.solr = {
60 after = [ "network.target" "remote-fs.target" "nss-lookup.target" "systemd-journald-dev-log.socket" ];
61 wantedBy = [ "multi-user.target" ];
64 SOLR_HOME = "${cfg.stateDir}/data";
65 LOG4J_PROPS = "${cfg.stateDir}/log4j2.xml";
66 SOLR_LOGS_DIR = "${cfg.stateDir}/logs";
67 SOLR_PORT = "${toString cfg.port}";
74 mkdir -p "${cfg.stateDir}/data";
75 mkdir -p "${cfg.stateDir}/logs";
77 if ! test -e "${cfg.stateDir}/data/solr.xml"; then
78 install -D -m0640 ${cfg.package}/server/solr/solr.xml "${cfg.stateDir}/data/solr.xml"
79 install -D -m0640 ${cfg.package}/server/solr/zoo.cfg "${cfg.stateDir}/data/zoo.cfg"
82 if ! test -e "${cfg.stateDir}/log4j2.xml"; then
83 install -D -m0640 ${cfg.package}/server/resources/log4j2.xml "${cfg.stateDir}/log4j2.xml"
90 ExecStart="${cfg.package}/bin/solr start -f -a \"${concatStringsSep " " cfg.extraJavaOptions}\"";
91 ExecStop="${cfg.package}/bin/solr stop";
95 users.users = optionalAttrs (cfg.user == "solr") {
100 uid = config.ids.uids.solr;
104 users.groups = optionalAttrs (cfg.group == "solr") {
105 solr.gid = config.ids.gids.solr;