1 { config, lib, pkgs, ... }:
7 cfg = config.services.jira;
9 pkg = cfg.package.override (optionalAttrs cfg.sso.enable {
10 enableSSO = cfg.sso.enable;
13 crowdProperties = pkgs.writeText "crowd.properties" ''
14 application.name ${cfg.sso.applicationName}
15 application.password @NIXOS_JIRA_CROWD_SSO_PWD@
16 application.login.url ${cfg.sso.crowd}/console/
18 crowd.server.url ${cfg.sso.crowd}/services/
19 crowd.base.url ${cfg.sso.crowd}/
21 session.isauthenticated session.isauthenticated
22 session.tokenkey session.tokenkey
23 session.validationinterval ${toString cfg.sso.validationInterval}
24 session.lastvalidation session.lastvalidation
32 enable = mkEnableOption "Atlassian JIRA service";
37 description = "User which runs JIRA.";
43 description = "Group which runs JIRA.";
48 default = "/var/lib/jira";
49 description = "Home directory of the JIRA instance.";
52 listenAddress = mkOption {
54 default = "127.0.0.1";
55 description = "Address to listen on.";
58 listenPort = mkOption {
61 description = "Port to listen on.";
64 catalinaOptions = mkOption {
65 type = types.listOf types.str;
67 example = [ "-Xms1024m" "-Xmx2048m" ];
68 description = "Java options to pass to catalina/tomcat.";
72 enable = mkEnableOption "reverse proxy support";
76 example = "jira.example.com";
77 description = "Virtual hostname at the proxy";
84 description = "Port used at the proxy";
91 description = "Protocol used at the proxy.";
97 description = "Whether the connections to the proxy should be considered secure.";
102 enable = mkEnableOption "SSO with Atlassian Crowd";
106 example = "http://localhost:8095/crowd";
107 description = "Crowd Base URL without trailing slash";
110 applicationName = mkOption {
113 description = "Exact name of this JIRA instance in Crowd";
116 applicationPasswordFile = mkOption {
118 description = "Path to the file containing the application password of this JIRA instance in Crowd";
121 validationInterval = mkOption {
126 Set to 0, if you want authentication checks to occur on each
127 request. Otherwise set to the number of minutes between request
128 to validate if the user is logged in or out of the Crowd SSO
129 server. Setting this value to 1 or higher will increase the
130 performance of Crowd's integration.
135 package = mkPackageOption pkgs "atlassian-jira" { };
137 jrePackage = mkPackageOption pkgs "oraclejre8" {
138 extraDescription = ''
140 Atlassian only supports the Oracle JRE (JRASERVER-46152).
147 config = mkIf cfg.enable {
148 users.users.${cfg.user} = {
154 users.groups.${cfg.group} = {};
156 systemd.tmpfiles.rules = [
157 "d '${cfg.home}' - ${cfg.user} - - -"
158 "d /run/atlassian-jira - - - - -"
160 "L+ /run/atlassian-jira/home - - - - ${cfg.home}"
161 "L+ /run/atlassian-jira/logs - - - - ${cfg.home}/logs"
162 "L+ /run/atlassian-jira/work - - - - ${cfg.home}/work"
163 "L+ /run/atlassian-jira/temp - - - - ${cfg.home}/temp"
164 "L+ /run/atlassian-jira/server.xml - - - - ${cfg.home}/server.xml"
167 systemd.services.atlassian-jira = {
168 description = "Atlassian JIRA";
170 wantedBy = [ "multi-user.target" ];
171 requires = [ "postgresql.service" ];
172 after = [ "postgresql.service" ];
174 path = [ cfg.jrePackage pkgs.bash ];
177 JIRA_USER = cfg.user;
178 JIRA_HOME = cfg.home;
179 JAVA_HOME = "${cfg.jrePackage}";
180 CATALINA_OPTS = concatStringsSep " " cfg.catalinaOptions;
181 JAVA_OPTS = mkIf cfg.sso.enable "-Dcrowd.properties=${cfg.home}/crowd.properties";
185 mkdir -p ${cfg.home}/{logs,work,temp,deploy}
187 sed -e 's,port="8080",port="${toString cfg.listenPort}" address="${cfg.listenAddress}",' \
188 '' + (lib.optionalString cfg.proxy.enable ''
189 -e 's,protocol="HTTP/1.1",protocol="HTTP/1.1" proxyName="${cfg.proxy.name}" proxyPort="${toString cfg.proxy.port}" scheme="${cfg.proxy.scheme}" secure="${toString cfg.proxy.secure}",' \
191 ${pkg}/conf/server.xml.dist > ${cfg.home}/server.xml
193 ${optionalString cfg.sso.enable ''
194 install -m660 ${crowdProperties} ${cfg.home}/crowd.properties
195 ${pkgs.replace-secret}/bin/replace-secret \
196 '@NIXOS_JIRA_CROWD_SSO_PWD@' \
197 ${cfg.sso.applicationPasswordFile} \
198 ${cfg.home}/crowd.properties
206 Restart = "on-failure";
208 ExecStart = "${pkg}/bin/start-jira.sh -fg";
209 ExecStop = "${pkg}/bin/stop-jira.sh";
215 (mkRemovedOptionModule [ "services" "jira" "sso" "applicationPassword" ] ''
216 Use `applicationPasswordFile` instead!