2014-04-14 15:26:48 +01:00
|
|
|
{ config, lib, pkgs, serverInfo, ... }:
|
2009-08-30 20:11:47 +01:00
|
|
|
|
2014-04-14 15:26:48 +01:00
|
|
|
with lib;
|
2010-02-10 12:39:47 +00:00
|
|
|
|
2009-08-30 20:11:47 +01:00
|
|
|
let
|
2011-09-14 19:20:50 +01:00
|
|
|
|
2009-08-30 20:45:15 +01:00
|
|
|
# Build a Subversion instance with Apache modules and Swig/Python bindings.
|
2016-04-07 10:37:19 +01:00
|
|
|
subversion = pkgs.subversion.override {
|
2009-08-30 20:45:15 +01:00
|
|
|
bdbSupport = true;
|
|
|
|
httpServer = true;
|
|
|
|
pythonBindings = true;
|
2016-04-07 10:37:19 +01:00
|
|
|
apacheHttpd = httpd;
|
|
|
|
};
|
2010-02-10 12:39:47 +00:00
|
|
|
|
2016-04-07 10:37:19 +01:00
|
|
|
httpd = serverInfo.serverConfig.package;
|
|
|
|
|
|
|
|
versionPre24 = versionOlder httpd.version "2.4";
|
|
|
|
|
2009-08-30 20:11:47 +01:00
|
|
|
in
|
2010-02-10 12:39:47 +00:00
|
|
|
|
2009-08-30 20:11:47 +01:00
|
|
|
{
|
2010-02-10 12:39:47 +00:00
|
|
|
|
2009-08-30 20:11:47 +01:00
|
|
|
options = {
|
2011-09-14 19:20:50 +01:00
|
|
|
|
2009-08-30 20:11:47 +01:00
|
|
|
projectsLocation = mkOption {
|
|
|
|
description = "URL path in which Trac projects can be accessed";
|
|
|
|
default = "/projects";
|
|
|
|
};
|
2011-09-14 19:20:50 +01:00
|
|
|
|
2009-09-04 16:58:04 +01:00
|
|
|
projects = mkOption {
|
|
|
|
description = "List of projects that should be provided by Trac. If they are not defined yet empty projects are created.";
|
|
|
|
default = [];
|
2010-02-10 12:39:47 +00:00
|
|
|
example =
|
|
|
|
[ { identifier = "myproject";
|
|
|
|
name = "My Project";
|
|
|
|
databaseURL="postgres://root:password@/tracdb";
|
|
|
|
subversionRepository="/data/subversion/myproject";
|
|
|
|
}
|
|
|
|
];
|
2009-09-04 16:58:04 +01:00
|
|
|
};
|
2011-09-14 19:20:50 +01:00
|
|
|
|
2009-09-04 16:58:04 +01:00
|
|
|
user = mkOption {
|
|
|
|
default = "wwwrun";
|
2010-02-10 12:39:47 +00:00
|
|
|
description = "User account under which Trac runs.";
|
2009-09-04 16:58:04 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
group = mkOption {
|
|
|
|
default = "wwwrun";
|
2010-02-10 12:39:47 +00:00
|
|
|
description = "Group under which Trac runs.";
|
2009-09-04 16:58:04 +01:00
|
|
|
};
|
2011-04-09 17:05:36 +01:00
|
|
|
|
|
|
|
ldapAuthentication = {
|
|
|
|
enable = mkOption {
|
|
|
|
default = false;
|
|
|
|
description = "Enable the ldap authentication in trac";
|
|
|
|
};
|
|
|
|
|
|
|
|
url = mkOption {
|
|
|
|
default = "ldap://127.0.0.1/dc=example,dc=co,dc=ke?uid?sub?(objectClass=inetOrgPerson)";
|
|
|
|
description = "URL of the LDAP authentication";
|
|
|
|
};
|
|
|
|
|
|
|
|
name = mkOption {
|
|
|
|
default = "Trac server";
|
|
|
|
description = "AuthName";
|
|
|
|
};
|
|
|
|
};
|
2011-09-14 19:20:50 +01:00
|
|
|
|
2009-08-30 20:11:47 +01:00
|
|
|
};
|
|
|
|
|
2010-02-10 12:39:47 +00:00
|
|
|
extraModules = singleton
|
|
|
|
{ name = "python"; path = "${pkgs.mod_python}/modules/mod_python.so"; };
|
2011-09-14 19:20:50 +01:00
|
|
|
|
2009-08-30 20:11:47 +01:00
|
|
|
extraConfig = ''
|
2009-09-04 16:58:04 +01:00
|
|
|
<Location ${config.projectsLocation}>
|
|
|
|
SetHandler mod_python
|
|
|
|
PythonHandler trac.web.modpython_frontend
|
|
|
|
PythonOption TracEnvParentDir /var/trac/projects
|
|
|
|
PythonOption TracUriRoot ${config.projectsLocation}
|
|
|
|
PythonOption PYTHON_EGG_CACHE /var/trac/egg-cache
|
|
|
|
</Location>
|
2011-04-09 17:05:36 +01:00
|
|
|
${if config.ldapAuthentication.enable then ''
|
2011-04-11 20:43:48 +01:00
|
|
|
<LocationMatch "^${config.projectsLocation}[^/]+/login$">
|
2011-04-09 17:05:36 +01:00
|
|
|
AuthType Basic
|
|
|
|
AuthName "${config.ldapAuthentication.name}"
|
|
|
|
AuthBasicProvider "ldap"
|
|
|
|
AuthLDAPURL "${config.ldapAuthentication.url}"
|
2016-04-07 10:37:19 +01:00
|
|
|
${if versionPre24 then "authzldapauthoritative Off" else ""}
|
2011-04-09 17:05:36 +01:00
|
|
|
require valid-user
|
2013-07-17 14:28:36 +01:00
|
|
|
</LocationMatch>
|
2011-04-09 17:05:36 +01:00
|
|
|
'' else ""}
|
2009-08-30 20:11:47 +01:00
|
|
|
'';
|
2011-09-14 19:20:50 +01:00
|
|
|
|
2010-02-10 12:39:47 +00:00
|
|
|
globalEnvVars = singleton
|
2009-08-30 20:11:47 +01:00
|
|
|
{ name = "PYTHONPATH";
|
2010-02-10 12:39:47 +00:00
|
|
|
value =
|
2016-04-14 16:14:28 +01:00
|
|
|
makeSearchPathOutput "lib" "lib/${pkgs.python.libPrefix}/site-packages"
|
2010-02-10 12:39:47 +00:00
|
|
|
[ pkgs.mod_python
|
|
|
|
pkgs.pythonPackages.trac
|
2017-01-05 17:37:33 +00:00
|
|
|
pkgs.pythonPackages.setuptools
|
2010-02-10 12:39:47 +00:00
|
|
|
pkgs.pythonPackages.genshi
|
|
|
|
pkgs.pythonPackages.psycopg2
|
|
|
|
subversion
|
|
|
|
];
|
|
|
|
};
|
2011-09-14 19:20:50 +01:00
|
|
|
|
2009-09-04 16:58:04 +01:00
|
|
|
startupScript = pkgs.writeScript "activateTrac" ''
|
|
|
|
mkdir -p /var/trac
|
|
|
|
chown ${config.user}:${config.group} /var/trac
|
2011-09-14 19:20:50 +01:00
|
|
|
|
2010-02-10 12:39:47 +00:00
|
|
|
${concatMapStrings (project:
|
2009-09-04 16:58:04 +01:00
|
|
|
''
|
|
|
|
if [ ! -d /var/trac/${project.identifier} ]
|
2010-04-15 16:47:26 +01:00
|
|
|
then
|
|
|
|
export PYTHONPATH=${pkgs.pythonPackages.psycopg2}/lib/${pkgs.python.libPrefix}/site-packages
|
|
|
|
${pkgs.pythonPackages.trac}/bin/trac-admin /var/trac/${project.identifier} initenv "${project.name}" "${project.databaseURL}" svn "${project.subversionRepository}"
|
|
|
|
fi
|
2009-09-04 16:58:04 +01:00
|
|
|
'' ) (config.projects)}
|
|
|
|
'';
|
2011-09-14 19:20:50 +01:00
|
|
|
|
2009-08-30 20:11:47 +01:00
|
|
|
}
|