2016-10-09 11:45:10 +02:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
|
|
|
|
cfg = config.services.confluence;
|
|
|
|
|
2019-02-13 09:08:13 +01:00
|
|
|
pkg = cfg.package.override (optionalAttrs cfg.sso.enable {
|
2017-06-17 18:32:00 +02:00
|
|
|
enableSSO = cfg.sso.enable;
|
|
|
|
crowdProperties = ''
|
|
|
|
application.name ${cfg.sso.applicationName}
|
|
|
|
application.password ${cfg.sso.applicationPassword}
|
|
|
|
application.login.url ${cfg.sso.crowd}/console/
|
|
|
|
|
|
|
|
crowd.server.url ${cfg.sso.crowd}/services/
|
|
|
|
crowd.base.url ${cfg.sso.crowd}/
|
|
|
|
|
|
|
|
session.isauthenticated session.isauthenticated
|
|
|
|
session.tokenkey session.tokenkey
|
|
|
|
session.validationinterval ${toString cfg.sso.validationInterval}
|
|
|
|
session.lastvalidation session.lastvalidation
|
|
|
|
'';
|
2017-06-18 06:09:31 +02:00
|
|
|
});
|
2016-10-09 11:45:10 +02:00
|
|
|
|
|
|
|
in
|
|
|
|
|
|
|
|
{
|
|
|
|
options = {
|
|
|
|
services.confluence = {
|
|
|
|
enable = mkEnableOption "Atlassian Confluence service";
|
|
|
|
|
|
|
|
user = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "confluence";
|
|
|
|
description = "User which runs confluence.";
|
|
|
|
};
|
|
|
|
|
|
|
|
group = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "confluence";
|
|
|
|
description = "Group which runs confluence.";
|
|
|
|
};
|
|
|
|
|
|
|
|
home = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "/var/lib/confluence";
|
|
|
|
description = "Home directory of the confluence instance.";
|
|
|
|
};
|
|
|
|
|
|
|
|
listenAddress = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "127.0.0.1";
|
|
|
|
description = "Address to listen on.";
|
|
|
|
};
|
|
|
|
|
|
|
|
listenPort = mkOption {
|
|
|
|
type = types.int;
|
|
|
|
default = 8090;
|
|
|
|
description = "Port to listen on.";
|
|
|
|
};
|
|
|
|
|
|
|
|
catalinaOptions = mkOption {
|
|
|
|
type = types.listOf types.str;
|
|
|
|
default = [];
|
|
|
|
example = [ "-Xms1024m" "-Xmx2048m" "-Dconfluence.disable.peopledirectory.all=true" ];
|
|
|
|
description = "Java options to pass to catalina/tomcat.";
|
|
|
|
};
|
|
|
|
|
|
|
|
proxy = {
|
|
|
|
enable = mkEnableOption "proxy support";
|
|
|
|
|
|
|
|
name = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
example = "confluence.example.com";
|
|
|
|
description = "Virtual hostname at the proxy";
|
|
|
|
};
|
|
|
|
|
|
|
|
port = mkOption {
|
|
|
|
type = types.int;
|
|
|
|
default = 443;
|
|
|
|
example = 80;
|
|
|
|
description = "Port used at the proxy";
|
|
|
|
};
|
|
|
|
|
|
|
|
scheme = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "https";
|
|
|
|
example = "http";
|
|
|
|
description = "Protocol used at the proxy.";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2017-06-17 18:32:00 +02:00
|
|
|
sso = {
|
|
|
|
enable = mkEnableOption "SSO with Atlassian Crowd";
|
|
|
|
|
|
|
|
crowd = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
example = "http://localhost:8095/crowd";
|
|
|
|
description = "Crowd Base URL without trailing slash";
|
|
|
|
};
|
|
|
|
|
|
|
|
applicationName = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
example = "jira";
|
|
|
|
description = "Exact name of this Confluence instance in Crowd";
|
|
|
|
};
|
|
|
|
|
|
|
|
applicationPassword = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
description = "Application password of this Confluence instance in Crowd";
|
|
|
|
};
|
|
|
|
|
|
|
|
validationInterval = mkOption {
|
|
|
|
type = types.int;
|
|
|
|
default = 2;
|
|
|
|
example = 0;
|
|
|
|
description = ''
|
|
|
|
Set to 0, if you want authentication checks to occur on each
|
|
|
|
request. Otherwise set to the number of minutes between request
|
|
|
|
to validate if the user is logged in or out of the Crowd SSO
|
|
|
|
server. Setting this value to 1 or higher will increase the
|
|
|
|
performance of Crowd's integration.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2019-02-13 09:08:13 +01:00
|
|
|
package = mkOption {
|
|
|
|
type = types.package;
|
|
|
|
default = pkgs.atlassian-confluence;
|
|
|
|
defaultText = "pkgs.atlassian-confluence";
|
|
|
|
description = "Atlassian Confluence package to use.";
|
|
|
|
};
|
2017-06-17 18:32:00 +02:00
|
|
|
|
2017-11-08 20:26:03 +01:00
|
|
|
jrePackage = mkOption {
|
2016-10-09 11:45:10 +02:00
|
|
|
type = types.package;
|
2017-11-08 20:26:03 +01:00
|
|
|
default = pkgs.oraclejre8;
|
2017-11-09 20:28:49 +01:00
|
|
|
defaultText = "pkgs.oraclejre8";
|
2017-11-08 20:26:03 +01:00
|
|
|
description = "Note that Atlassian only support the Oracle JRE (JRASERVER-46152).";
|
2016-10-09 11:45:10 +02:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
2018-06-30 01:58:35 +02:00
|
|
|
users.users."${cfg.user}" = {
|
2016-10-09 11:45:10 +02:00
|
|
|
isSystemUser = true;
|
|
|
|
group = cfg.group;
|
|
|
|
};
|
|
|
|
|
2018-06-30 01:58:35 +02:00
|
|
|
users.groups."${cfg.group}" = {};
|
2016-10-09 11:45:10 +02:00
|
|
|
|
|
|
|
systemd.services.confluence = {
|
|
|
|
description = "Atlassian Confluence";
|
|
|
|
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
requires = [ "postgresql.service" ];
|
|
|
|
after = [ "postgresql.service" ];
|
|
|
|
|
2017-04-24 15:43:49 +02:00
|
|
|
path = [ cfg.jrePackage pkgs.bash ];
|
2016-10-09 11:45:10 +02:00
|
|
|
|
|
|
|
environment = {
|
|
|
|
CONF_USER = cfg.user;
|
|
|
|
JAVA_HOME = "${cfg.jrePackage}";
|
|
|
|
CATALINA_OPTS = concatStringsSep " " cfg.catalinaOptions;
|
|
|
|
};
|
|
|
|
|
|
|
|
preStart = ''
|
|
|
|
mkdir -p ${cfg.home}/{logs,work,temp,deploy}
|
|
|
|
|
|
|
|
mkdir -p /run/confluence
|
|
|
|
ln -sf ${cfg.home}/{logs,work,temp,server.xml} /run/confluence
|
|
|
|
ln -sf ${cfg.home} /run/confluence/home
|
|
|
|
|
2018-11-22 08:50:59 +01:00
|
|
|
chown ${cfg.user} ${cfg.home}
|
2016-10-09 11:45:10 +02:00
|
|
|
|
|
|
|
sed -e 's,port="8090",port="${toString cfg.listenPort}" address="${cfg.listenAddress}",' \
|
|
|
|
'' + (lib.optionalString cfg.proxy.enable ''
|
|
|
|
-e 's,protocol="org.apache.coyote.http11.Http11NioProtocol",protocol="org.apache.coyote.http11.Http11NioProtocol" proxyName="${cfg.proxy.name}" proxyPort="${toString cfg.proxy.port}" scheme="${cfg.proxy.scheme}",' \
|
|
|
|
'') + ''
|
|
|
|
${pkg}/conf/server.xml.dist > ${cfg.home}/server.xml
|
|
|
|
'';
|
|
|
|
|
|
|
|
serviceConfig = {
|
|
|
|
User = cfg.user;
|
|
|
|
Group = cfg.group;
|
|
|
|
PrivateTmp = true;
|
|
|
|
PermissionsStartOnly = true;
|
2017-11-08 20:20:49 +01:00
|
|
|
ExecStart = "${pkg}/bin/start-confluence.sh -fg";
|
|
|
|
ExecStop = "${pkg}/bin/stop-confluence.sh";
|
2016-10-09 11:45:10 +02:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|