2008-02-14 09:54:25 +00:00
|
|
|
{config, pkgs, serverInfo}:
|
2008-02-05 16:25:07 +00:00
|
|
|
|
|
|
|
let
|
|
|
|
|
2008-02-14 09:54:25 +00:00
|
|
|
inherit (pkgs.lib) mkOption;
|
|
|
|
|
|
|
|
urlPrefix = config.urlPrefix;
|
|
|
|
dbDir = "${config.dataDir}/db";
|
|
|
|
reposDir = "${config.dataDir}/repos";
|
|
|
|
backupsDir = "${config.dataDir}/backup";
|
|
|
|
distsDir = "${config.dataDir}/dist";
|
|
|
|
tmpDir = "${config.dataDir}/tmp";
|
|
|
|
logDir = "${config.dataDir}/log";
|
2008-02-12 12:56:39 +00:00
|
|
|
postCommitHook = "/var/run/current-system/sw/bin/svn-server-post-commit-hook";
|
|
|
|
fsType = "fsfs";
|
2008-02-19 14:54:19 +00:00
|
|
|
adminAddr = serverInfo.adminAddr;
|
2008-02-14 09:54:25 +00:00
|
|
|
|
2008-02-05 16:25:07 +00:00
|
|
|
|
|
|
|
|
|
|
|
# Build a Subversion instance with Apache modules and Swig/Python bindings.
|
|
|
|
subversion = import ../../../nixpkgs/pkgs/applications/version-management/subversion-1.4.x {
|
|
|
|
inherit (pkgs) fetchurl stdenv apr aprutil neon expat swig zlib;
|
|
|
|
bdbSupport = true;
|
|
|
|
httpServer = true;
|
|
|
|
sslSupport = true;
|
|
|
|
compressionSupport = true;
|
|
|
|
pythonBindings = true;
|
|
|
|
httpd = pkgs.apacheHttpd;
|
|
|
|
};
|
|
|
|
|
2008-02-12 12:56:39 +00:00
|
|
|
|
|
|
|
# Build the maintenance scripts and commit hooks.
|
|
|
|
scripts = substituteInAll {
|
|
|
|
name = "svn-server-scripts";
|
|
|
|
src = pkgs.lib.cleanSource ../../../services/subversion/src/scripts;
|
|
|
|
|
|
|
|
# The variables to substitute:
|
|
|
|
|
|
|
|
inherit reposDir dbDir logDir distsDir backupsDir tmpDir
|
2008-02-14 09:54:25 +00:00
|
|
|
urlPrefix adminAddr fsType subversion postCommitHook;
|
|
|
|
inherit (config) notificationSender userCreationDomain;
|
|
|
|
orgUrl = config.organisation.url;
|
|
|
|
orgLogoUrl = config.organisation.logo;
|
|
|
|
orgName = config.organisation.name;
|
2008-02-12 12:56:39 +00:00
|
|
|
|
|
|
|
perl = "${pkgs.perl}/bin/perl";
|
|
|
|
|
|
|
|
sendmail = "${pkgs.ssmtp}/sbin/sendmail";
|
|
|
|
|
|
|
|
inherit (pkgs) libxslt enscript db4 coreutils bzip2;
|
|
|
|
|
|
|
|
inherit (serverInfo) canonicalName;
|
2008-02-19 17:37:05 +00:00
|
|
|
|
|
|
|
inherit (serverInfo.serverConfig) user group;
|
2008-02-12 12:56:39 +00:00
|
|
|
|
|
|
|
# Urgh, most of these are dependencies of Email::Send, should figure them out automatically.
|
|
|
|
perlFlags = map (x: "-I${x}/lib/site_perl") [
|
|
|
|
pkgs.perlBerkeleyDB pkgs.perlEmailSend pkgs.perlEmailSimple
|
|
|
|
pkgs.perlModulePluggable pkgs.perlReturnValue pkgs.perlEmailAddress
|
|
|
|
pkgs.perlCryptPasswordMD5 pkgs.perlStringMkPasswd
|
|
|
|
];
|
|
|
|
|
|
|
|
# Do a syntax check on the generated file.
|
2008-02-14 07:42:52 +00:00
|
|
|
postInstall = ''
|
2008-02-14 09:54:25 +00:00
|
|
|
$perl -c -T $out/cgi-bin/repoman.pl
|
|
|
|
$perl -c $out/bin/svn-server-create-user.pl
|
2008-02-14 07:42:52 +00:00
|
|
|
'';
|
2008-02-12 12:56:39 +00:00
|
|
|
};
|
|
|
|
|
2008-02-05 16:25:07 +00:00
|
|
|
|
|
|
|
# Build our custom authentication modules.
|
|
|
|
authModules = import ../../../services/subversion/src/auth {
|
|
|
|
inherit (pkgs) stdenv apacheHttpd;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2008-02-11 11:51:51 +00:00
|
|
|
commonAuth = ''
|
2008-02-05 16:25:07 +00:00
|
|
|
AuthType Basic
|
|
|
|
AuthName "Subversion repositories"
|
2008-02-14 09:54:25 +00:00
|
|
|
AuthBasicProvider dbm
|
|
|
|
AuthDBMType DB
|
|
|
|
AuthDBMUserFile ${dbDir}/svn-users
|
2008-02-11 11:51:51 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
|
|
|
|
# Access controls for /repos and /repos-xml.
|
|
|
|
reposConfig = dirName: ''
|
|
|
|
${commonAuth}
|
2008-02-05 16:25:07 +00:00
|
|
|
|
|
|
|
AuthAllowNone on
|
|
|
|
|
2008-02-14 09:54:25 +00:00
|
|
|
AuthzRepoPrefix ${urlPrefix}/${dirName}/
|
2008-02-05 16:25:07 +00:00
|
|
|
AuthzRepoDBType DB
|
|
|
|
AuthzRepoReaders ${dbDir}/svn-readers
|
|
|
|
AuthzRepoWriters ${dbDir}/svn-writers
|
|
|
|
|
|
|
|
<LimitExcept GET PROPFIND OPTIONS REPORT>
|
|
|
|
Require repo-writer
|
|
|
|
</LimitExcept>
|
|
|
|
|
|
|
|
<Limit GET PROPFIND OPTIONS REPORT>
|
|
|
|
Require repo-reader
|
|
|
|
</Limit>
|
|
|
|
|
|
|
|
DAV svn
|
|
|
|
SVNParentPath ${reposDir}
|
2008-02-14 09:54:25 +00:00
|
|
|
SVNAutoversioning ${if config.autoVersioning then "on" else "off"}
|
2008-02-05 16:25:07 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
|
|
|
|
# Build ViewVC.
|
|
|
|
viewvc = import ../../../services/subversion/src/viewvc {
|
|
|
|
inherit (pkgs) fetchurl stdenv python enscript;
|
2008-02-14 09:54:25 +00:00
|
|
|
inherit urlPrefix reposDir adminAddr subversion;
|
2008-02-05 16:25:07 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
viewerConfig = dirName: ''
|
2008-02-11 11:51:51 +00:00
|
|
|
${commonAuth}
|
2008-02-05 16:25:07 +00:00
|
|
|
AuthAllowNone on
|
2008-02-14 09:54:25 +00:00
|
|
|
AuthzRepoPrefix ${urlPrefix}/${dirName}/
|
2008-02-05 16:25:07 +00:00
|
|
|
AuthzRepoDBType DB
|
|
|
|
AuthzRepoReaders ${dbDir}/svn-readers
|
|
|
|
Require repo-reader
|
|
|
|
'';
|
|
|
|
|
|
|
|
|
|
|
|
viewvcConfig = ''
|
2008-02-14 09:54:25 +00:00
|
|
|
ScriptAlias ${urlPrefix}/viewvc ${viewvc}/viewvc/bin/mod_python/viewvc.py
|
2008-02-05 16:25:07 +00:00
|
|
|
|
2008-02-14 09:54:25 +00:00
|
|
|
<Location ${urlPrefix}/viewvc>
|
2008-02-05 16:25:07 +00:00
|
|
|
AddHandler python-program .py
|
|
|
|
# Note: we write \" instead of ' to work around a lexer bug in Nix 0.11.
|
|
|
|
PythonPath "[\"${viewvc}/viewvc/bin/mod_python\", \"${subversion}/lib/python2.4/site-packages\"] + sys.path"
|
|
|
|
PythonHandler handler
|
|
|
|
${viewerConfig "viewvc"}
|
|
|
|
</Location>
|
|
|
|
|
2008-02-14 09:54:25 +00:00
|
|
|
Alias ${urlPrefix}/viewvc-doc ${viewvc}/viewvc/templates/docroot
|
2008-02-05 16:25:07 +00:00
|
|
|
|
2008-02-14 09:54:25 +00:00
|
|
|
Redirect permanent ${urlPrefix}/viewcvs ${serverInfo.canonicalName}/${urlPrefix}/viewvc
|
2008-02-05 16:25:07 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
|
|
|
|
# Build WebSVN.
|
|
|
|
websvn = import ../../../services/subversion/src/websvn {
|
|
|
|
inherit (pkgs) fetchurl stdenv writeText enscript gnused diffutils;
|
2008-02-14 09:54:25 +00:00
|
|
|
inherit urlPrefix reposDir subversion;
|
2008-02-05 16:25:07 +00:00
|
|
|
cacheDir = tmpDir;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
websvnConfig = ''
|
2008-02-14 09:54:25 +00:00
|
|
|
Alias ${urlPrefix}/websvn ${websvn}/wsvn.php
|
|
|
|
Alias ${urlPrefix}/templates ${websvn}/templates
|
2008-02-05 16:25:07 +00:00
|
|
|
|
2008-02-14 09:54:25 +00:00
|
|
|
<Location ${urlPrefix}/websvn>
|
2008-02-05 16:25:07 +00:00
|
|
|
${viewerConfig "websvn"}
|
|
|
|
</Location>
|
|
|
|
|
|
|
|
<Directory ${websvn}/templates>
|
|
|
|
Order allow,deny
|
|
|
|
Allow from all
|
|
|
|
</Directory>
|
|
|
|
'';
|
|
|
|
|
|
|
|
|
2008-02-12 12:56:39 +00:00
|
|
|
distConfig = ''
|
2008-02-14 09:54:25 +00:00
|
|
|
Alias ${urlPrefix}/dist ${distsDir}
|
2008-02-05 16:25:07 +00:00
|
|
|
|
2008-02-12 12:56:39 +00:00
|
|
|
<Directory "${distsDir}">
|
|
|
|
AllowOverride None
|
|
|
|
Options Indexes FollowSymLinks
|
|
|
|
Order allow,deny
|
|
|
|
Allow from all
|
|
|
|
IndexOptions +SuppressDescription +NameWidth=*
|
|
|
|
IndexIgnore *.rev *.lock
|
2008-02-14 09:54:25 +00:00
|
|
|
IndexStyleSheet ${urlPrefix}/style.css
|
2008-02-12 12:56:39 +00:00
|
|
|
</Directory>
|
|
|
|
|
2008-02-14 09:54:25 +00:00
|
|
|
<Location ${urlPrefix}/dist>
|
2008-02-12 12:56:39 +00:00
|
|
|
${viewerConfig "dist"}
|
|
|
|
</Location>
|
|
|
|
'';
|
|
|
|
|
2008-02-05 16:25:07 +00:00
|
|
|
|
|
|
|
repomanConfig = ''
|
2008-02-14 09:54:25 +00:00
|
|
|
ScriptAlias ${urlPrefix}/repoman ${scripts}/cgi-bin/repoman.pl
|
2008-02-11 11:51:51 +00:00
|
|
|
|
2008-02-14 09:54:25 +00:00
|
|
|
<Location ${urlPrefix}/repoman/listdetails>
|
2008-02-11 11:51:51 +00:00
|
|
|
${commonAuth}
|
|
|
|
Require valid-user
|
|
|
|
</Location>
|
|
|
|
|
2008-02-14 09:54:25 +00:00
|
|
|
<Location ${urlPrefix}/repoman/adduser>
|
2008-02-11 11:51:51 +00:00
|
|
|
Order deny,allow
|
|
|
|
Deny from all
|
|
|
|
Allow from 127.0.0.1
|
2008-02-14 09:54:25 +00:00
|
|
|
Allow from ${config.userCreationDomain}
|
2008-02-11 11:51:51 +00:00
|
|
|
</Location>
|
|
|
|
|
2008-02-14 09:54:25 +00:00
|
|
|
<Location ${urlPrefix}/repoman/edituser>
|
2008-02-11 11:51:51 +00:00
|
|
|
${commonAuth}
|
|
|
|
Require valid-user
|
|
|
|
</Location>
|
|
|
|
|
2008-02-14 09:54:25 +00:00
|
|
|
<Location ${urlPrefix}/repoman/create>
|
2008-02-11 11:51:51 +00:00
|
|
|
${commonAuth}
|
|
|
|
Require valid-user
|
|
|
|
Order deny,allow
|
|
|
|
Deny from all
|
|
|
|
Allow from 127.0.0.1
|
2008-02-14 09:54:25 +00:00
|
|
|
Allow from ${config.userCreationDomain}
|
2008-02-11 11:51:51 +00:00
|
|
|
</Location>
|
|
|
|
|
2008-02-14 09:54:25 +00:00
|
|
|
<Location ${urlPrefix}/repoman/update>
|
2008-02-11 11:51:51 +00:00
|
|
|
${commonAuth}
|
|
|
|
Require valid-user
|
|
|
|
</Location>
|
|
|
|
|
2008-02-14 09:54:25 +00:00
|
|
|
<Location ${urlPrefix}/repoman/dump>
|
2008-02-11 11:51:51 +00:00
|
|
|
${viewerConfig "repoman/dump"}
|
|
|
|
</Location>
|
2008-02-05 16:25:07 +00:00
|
|
|
'';
|
|
|
|
|
2008-02-12 12:56:39 +00:00
|
|
|
|
|
|
|
staticFiles = substituteInSome {
|
|
|
|
name = "svn-static-files";
|
|
|
|
src = pkgs.lib.cleanSource ../../../services/subversion/root;
|
|
|
|
files = ["xsl/svnindex.xsl"];
|
2008-02-14 09:54:25 +00:00
|
|
|
inherit urlPrefix;
|
2008-02-12 12:56:39 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
staticFilesConfig = ''
|
2008-02-14 20:59:04 +00:00
|
|
|
Alias ${urlPrefix}/svn-files ${staticFiles}/
|
2008-02-12 12:56:39 +00:00
|
|
|
<Directory ${staticFiles}>
|
|
|
|
Order allow,deny
|
|
|
|
Allow from all
|
|
|
|
</Directory>
|
|
|
|
'';
|
|
|
|
|
2008-02-05 16:25:07 +00:00
|
|
|
|
2008-02-12 12:56:39 +00:00
|
|
|
# !!! should be in Nixpkgs.
|
2008-02-14 07:42:52 +00:00
|
|
|
substituteInSome = args: pkgs.stdenvUsingSetupNew2.mkDerivation ({
|
2008-02-12 12:56:39 +00:00
|
|
|
buildCommand = ''
|
|
|
|
ensureDir $out
|
|
|
|
cp -prd $src/* $out
|
|
|
|
chmod -R u+w $out
|
|
|
|
for i in $files; do
|
|
|
|
substituteAll $out/$i $out/$i
|
|
|
|
done
|
|
|
|
'';
|
|
|
|
} // args); # */
|
|
|
|
|
2008-02-14 07:42:52 +00:00
|
|
|
substituteInAll = args: pkgs.stdenvUsingSetupNew2.mkDerivation ({
|
2008-02-12 12:56:39 +00:00
|
|
|
buildCommand = ''
|
|
|
|
ensureDir $out
|
|
|
|
cp -prd $src/* $out
|
|
|
|
chmod -R u+w $out
|
|
|
|
find $out -type f -print | while read fn; do
|
|
|
|
substituteAll $fn $fn
|
|
|
|
done
|
|
|
|
eval "$postInstall"
|
|
|
|
'';
|
|
|
|
} // args); # */
|
2008-02-05 16:25:07 +00:00
|
|
|
|
2008-02-14 09:54:25 +00:00
|
|
|
|
|
|
|
in {
|
2008-02-05 16:25:07 +00:00
|
|
|
|
|
|
|
extraModulesPre = [
|
|
|
|
# Allow anonymous access to repositories that are world-readable
|
|
|
|
# without prompting for a username/password.
|
|
|
|
{ name = "authn_noauth"; path = "${authModules}/modules/mod_authn_noauth.so"; }
|
|
|
|
# Check whether the user is allowed read or write access to a
|
|
|
|
# repository.
|
|
|
|
{ name = "authz_dyn"; path = "${authModules}/modules/mod_authz_dyn.so"; }
|
|
|
|
];
|
|
|
|
|
|
|
|
extraModules = [
|
|
|
|
{ name = "python"; path = "${pkgs.mod_python}/modules/mod_python.so"; }
|
|
|
|
{ name = "php5"; path = "${pkgs.php}/modules/libphp5.so"; }
|
|
|
|
{ name = "dav_svn"; path = "${subversion}/modules/mod_dav_svn.so"; }
|
|
|
|
];
|
|
|
|
|
2008-02-14 09:54:25 +00:00
|
|
|
|
2008-02-05 16:25:07 +00:00
|
|
|
extraConfig = ''
|
|
|
|
|
2008-02-14 09:54:25 +00:00
|
|
|
<Location ${urlPrefix}/repos>
|
2008-02-05 16:25:07 +00:00
|
|
|
${reposConfig "repos"}
|
|
|
|
</Location>
|
|
|
|
|
2008-02-14 09:54:25 +00:00
|
|
|
<Location ${urlPrefix}/repos-xml>
|
2008-02-05 16:25:07 +00:00
|
|
|
${reposConfig "repos-xml"}
|
2008-02-14 20:59:04 +00:00
|
|
|
SVNIndexXSLT "${urlPrefix}/svn-files/xsl/svnindex.xsl"
|
2008-02-05 16:25:07 +00:00
|
|
|
</Location>
|
|
|
|
|
|
|
|
${viewvcConfig}
|
|
|
|
|
|
|
|
${websvnConfig}
|
|
|
|
|
|
|
|
${repomanConfig}
|
2008-02-12 12:56:39 +00:00
|
|
|
|
|
|
|
${distConfig}
|
|
|
|
|
|
|
|
${staticFilesConfig}
|
2008-02-19 16:52:24 +00:00
|
|
|
|
|
|
|
${if config.toplevelRedirect then ''
|
|
|
|
<Location />
|
|
|
|
DirectoryIndex repoman
|
|
|
|
</Location>
|
|
|
|
'' else ""}
|
2008-02-05 16:25:07 +00:00
|
|
|
|
|
|
|
'';
|
|
|
|
|
2008-02-14 09:54:25 +00:00
|
|
|
|
2008-02-05 16:25:07 +00:00
|
|
|
robotsEntries = ''
|
|
|
|
User-agent: *
|
2008-02-14 09:54:25 +00:00
|
|
|
Disallow: ${urlPrefix}/viewcvs/
|
|
|
|
Disallow: ${urlPrefix}/viewvc/
|
|
|
|
Disallow: ${urlPrefix}/websvn/
|
|
|
|
Disallow: ${urlPrefix}/repos-xml/
|
2008-02-05 16:25:07 +00:00
|
|
|
'';
|
|
|
|
|
2008-02-14 09:54:25 +00:00
|
|
|
|
2008-02-05 16:25:07 +00:00
|
|
|
# mod_python's own Python modules must be in the initial Python
|
|
|
|
# path, they cannot be set through the PythonPath directive.
|
|
|
|
globalEnvVars = [
|
|
|
|
{ name = "PYTHONPATH"; value = "${pkgs.mod_python}/lib/python2.4/site-packages"; }
|
|
|
|
];
|
|
|
|
|
2008-02-14 09:54:25 +00:00
|
|
|
|
2008-02-12 12:56:39 +00:00
|
|
|
extraServerPath = [
|
2008-02-05 16:25:07 +00:00
|
|
|
# Needed for ViewVC.
|
|
|
|
"${pkgs.diffutils}/bin"
|
|
|
|
"${pkgs.gnused}/bin"
|
|
|
|
];
|
2008-02-12 12:56:39 +00:00
|
|
|
|
2008-02-14 09:54:25 +00:00
|
|
|
|
2008-02-12 12:56:39 +00:00
|
|
|
extraPath = [scripts];
|
2008-02-19 17:37:05 +00:00
|
|
|
|
|
|
|
|
|
|
|
startupScript = "${scripts}/bin/svn-server-startup-hook.sh";
|
2008-02-05 16:25:07 +00:00
|
|
|
|
2008-02-14 09:54:25 +00:00
|
|
|
|
|
|
|
options = {
|
|
|
|
|
|
|
|
urlPrefix = mkOption {
|
|
|
|
default = "/subversion";
|
|
|
|
description = "
|
|
|
|
The URL prefix under which the Subversion service appears.
|
|
|
|
Use the empty string to have it appear in the server root.
|
|
|
|
";
|
|
|
|
};
|
|
|
|
|
2008-02-19 16:52:24 +00:00
|
|
|
toplevelRedirect = mkOption {
|
|
|
|
default = true;
|
|
|
|
description = "
|
|
|
|
Whether <varname>urlPrefix</varname> without any suffix
|
|
|
|
(except a slash) should redirect to
|
|
|
|
<varname>urlPrefix</varname><literal>/repoman</literal>.
|
|
|
|
";
|
|
|
|
};
|
|
|
|
|
2008-02-14 09:54:25 +00:00
|
|
|
notificationSender = mkOption {
|
|
|
|
default = "svn-server@example.org";
|
|
|
|
example = "svn-server@example.org";
|
|
|
|
description = "
|
|
|
|
The email address used in the Sender field of commit
|
|
|
|
notification messages sent by the Subversion subservice.
|
|
|
|
";
|
|
|
|
};
|
|
|
|
|
|
|
|
userCreationDomain = mkOption {
|
|
|
|
default = "example.org";
|
|
|
|
example = "example.org";
|
|
|
|
description = "
|
|
|
|
The domain from which user creation is allowed. A client can
|
|
|
|
only create a new user account if its IP address resolves to
|
|
|
|
this domain.
|
|
|
|
";
|
|
|
|
};
|
|
|
|
|
|
|
|
autoVersioning = mkOption {
|
|
|
|
default = false;
|
|
|
|
description = "
|
|
|
|
Whether you want the Subversion subservice to support
|
|
|
|
auto-versioning, which enables Subversion repositories to be
|
|
|
|
mounted as read/writable file systems on operating systems that
|
|
|
|
support WebDAV.
|
|
|
|
";
|
|
|
|
};
|
|
|
|
|
|
|
|
dataDir = mkOption {
|
2008-02-14 20:14:57 +00:00
|
|
|
example = "/data/subversion";
|
2008-02-14 09:54:25 +00:00
|
|
|
description = "
|
2008-02-14 20:14:57 +00:00
|
|
|
Path to the directory that holds the repositories, user database, etc.
|
2008-02-14 09:54:25 +00:00
|
|
|
";
|
|
|
|
};
|
|
|
|
|
|
|
|
organisation = {
|
|
|
|
|
|
|
|
name = mkOption {
|
|
|
|
default = null;
|
|
|
|
description = "
|
|
|
|
Name of the organization hosting the Subversion service.
|
|
|
|
";
|
|
|
|
};
|
|
|
|
|
|
|
|
url = mkOption {
|
|
|
|
default = null;
|
|
|
|
description = "
|
|
|
|
URL of the website of the organization hosting the Subversion service.
|
|
|
|
";
|
|
|
|
};
|
|
|
|
|
|
|
|
logo = mkOption {
|
|
|
|
default = null;
|
|
|
|
description = "
|
|
|
|
Logo the organization hosting the Subversion service.
|
|
|
|
";
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2008-02-14 13:20:26 +00:00
|
|
|
};
|
2008-02-14 09:54:25 +00:00
|
|
|
|
2008-02-05 16:25:07 +00:00
|
|
|
}
|