2009-08-31 16:56:19 +02:00
|
|
|
{ config, pkgs, serverInfo, ... }:
|
2009-08-30 21:11:47 +02:00
|
|
|
|
2010-02-10 13:39:47 +01:00
|
|
|
with pkgs.lib;
|
|
|
|
|
2009-08-30 21:11:47 +02:00
|
|
|
let
|
2011-09-14 20:20:50 +02:00
|
|
|
|
2009-08-30 21:45:15 +02:00
|
|
|
# Build a Subversion instance with Apache modules and Swig/Python bindings.
|
|
|
|
subversion = pkgs.subversion.override (origArgs: {
|
|
|
|
bdbSupport = true;
|
|
|
|
httpServer = true;
|
|
|
|
sslSupport = true;
|
|
|
|
compressionSupport = true;
|
|
|
|
pythonBindings = true;
|
|
|
|
});
|
2010-02-10 13:39:47 +01:00
|
|
|
|
|
|
|
pythonLib = p: "${p}/";
|
2011-09-14 20:20:50 +02:00
|
|
|
|
2009-08-30 21:11:47 +02:00
|
|
|
in
|
2010-02-10 13:39:47 +01:00
|
|
|
|
2009-08-30 21:11:47 +02:00
|
|
|
{
|
2010-02-10 13:39:47 +01:00
|
|
|
|
2009-08-30 21:11:47 +02:00
|
|
|
options = {
|
2011-09-14 20:20:50 +02:00
|
|
|
|
2009-08-30 21:11:47 +02:00
|
|
|
projectsLocation = mkOption {
|
|
|
|
description = "URL path in which Trac projects can be accessed";
|
|
|
|
default = "/projects";
|
|
|
|
};
|
2011-09-14 20:20:50 +02:00
|
|
|
|
2009-09-04 17:58:04 +02: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 13:39:47 +01:00
|
|
|
example =
|
|
|
|
[ { identifier = "myproject";
|
|
|
|
name = "My Project";
|
|
|
|
databaseURL="postgres://root:password@/tracdb";
|
|
|
|
subversionRepository="/data/subversion/myproject";
|
|
|
|
}
|
|
|
|
];
|
2009-09-04 17:58:04 +02:00
|
|
|
};
|
2011-09-14 20:20:50 +02:00
|
|
|
|
2009-09-04 17:58:04 +02:00
|
|
|
user = mkOption {
|
|
|
|
default = "wwwrun";
|
2010-02-10 13:39:47 +01:00
|
|
|
description = "User account under which Trac runs.";
|
2009-09-04 17:58:04 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
group = mkOption {
|
|
|
|
default = "wwwrun";
|
2010-02-10 13:39:47 +01:00
|
|
|
description = "Group under which Trac runs.";
|
2009-09-04 17:58:04 +02:00
|
|
|
};
|
2011-04-09 18:05:36 +02: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 20:20:50 +02:00
|
|
|
|
2009-08-30 21:11:47 +02:00
|
|
|
};
|
|
|
|
|
2010-02-10 13:39:47 +01:00
|
|
|
extraModules = singleton
|
|
|
|
{ name = "python"; path = "${pkgs.mod_python}/modules/mod_python.so"; };
|
2011-09-14 20:20:50 +02:00
|
|
|
|
2009-08-30 21:11:47 +02:00
|
|
|
extraConfig = ''
|
2009-09-04 17:58:04 +02: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 18:05:36 +02:00
|
|
|
${if config.ldapAuthentication.enable then ''
|
2011-04-11 21:43:48 +02:00
|
|
|
<LocationMatch "^${config.projectsLocation}[^/]+/login$">
|
2011-04-09 18:05:36 +02:00
|
|
|
AuthType Basic
|
|
|
|
AuthName "${config.ldapAuthentication.name}"
|
|
|
|
AuthBasicProvider "ldap"
|
|
|
|
AuthLDAPURL "${config.ldapAuthentication.url}"
|
|
|
|
authzldapauthoritative Off
|
|
|
|
require valid-user
|
|
|
|
'' else ""}
|
|
|
|
</LocationMatch>
|
2009-08-30 21:11:47 +02:00
|
|
|
'';
|
2011-09-14 20:20:50 +02:00
|
|
|
|
2010-02-10 13:39:47 +01:00
|
|
|
globalEnvVars = singleton
|
2009-08-30 21:11:47 +02:00
|
|
|
{ name = "PYTHONPATH";
|
2010-02-10 13:39:47 +01:00
|
|
|
value =
|
|
|
|
makeSearchPath "lib/${pkgs.python.libPrefix}/site-packages"
|
|
|
|
[ pkgs.mod_python
|
|
|
|
pkgs.pythonPackages.trac
|
|
|
|
pkgs.setuptools
|
|
|
|
pkgs.pythonPackages.genshi
|
|
|
|
pkgs.pythonPackages.psycopg2
|
2011-04-09 18:05:36 +02:00
|
|
|
pkgs.python.modules.sqlite3
|
2010-02-10 13:39:47 +01:00
|
|
|
subversion
|
|
|
|
];
|
|
|
|
};
|
2011-09-14 20:20:50 +02:00
|
|
|
|
2009-09-04 17:58:04 +02:00
|
|
|
startupScript = pkgs.writeScript "activateTrac" ''
|
|
|
|
mkdir -p /var/trac
|
|
|
|
chown ${config.user}:${config.group} /var/trac
|
2011-09-14 20:20:50 +02:00
|
|
|
|
2010-02-10 13:39:47 +01:00
|
|
|
${concatMapStrings (project:
|
2009-09-04 17:58:04 +02:00
|
|
|
''
|
|
|
|
if [ ! -d /var/trac/${project.identifier} ]
|
2010-04-15 17:47:26 +02: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 17:58:04 +02:00
|
|
|
'' ) (config.projects)}
|
|
|
|
'';
|
2011-09-14 20:20:50 +02:00
|
|
|
|
2009-08-30 21:11:47 +02:00
|
|
|
}
|