From 8d60cad42a4dfbab65c74f51baa7011b3c3e3e8d Mon Sep 17 00:00:00 2001 From: Rob Vermaas Date: Wed, 6 Oct 2010 11:21:15 +0000 Subject: [PATCH] mercurial: initial version for hgweb apache module svn path=/nixos/trunk/; revision=24111 --- .../web-servers/apache-httpd/mercurial.nix | 76 +++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 modules/services/web-servers/apache-httpd/mercurial.nix diff --git a/modules/services/web-servers/apache-httpd/mercurial.nix b/modules/services/web-servers/apache-httpd/mercurial.nix new file mode 100644 index 000000000000..cecc486160be --- /dev/null +++ b/modules/services/web-servers/apache-httpd/mercurial.nix @@ -0,0 +1,76 @@ +{ config, pkgs, serverInfo, servicesPath, ... }: + +let + inherit (pkgs) mercurial; + inherit (pkgs.lib) mkOption; + + urlPrefix = config.urlPrefix; + + cgi = pkgs.stdenv.mkDerivation { + name = "mercurial-cgi"; + buildCommand = '' + ensureDir $out + cp -v ${mercurial}/share/cgi-bin/hgweb.cgi $out + sed -i "s|/path/to/repo/or/config|$out/hgweb.config|" $out/hgweb.cgi + echo " + [collections] + ${config.dataDir} = ${config.dataDir} + [web] + style = gitweb + allow_push = * + " > $out/hgweb.config + ''; + }; + +in { + + extraConfig = '' + RewriteEngine on + RewriteRule /(.*) ${cgi}/hgweb.cgi/$1 + + + AuthType Basic + AuthName "Mercurial repositories" + AuthUserFile ${config.dataDir}/hgusers + + Require valid-user + + + + Order allow,deny + Allow from all + AllowOverride All + Options ExecCGI + AddHandler cgi-script .cgi + SetEnv PYTHONPATH "${mercurial}/lib/${pkgs.python.libPrefix}/site-packages" + PassEnv PYTHONPATH + + ''; + + robotsEntries = '' + User-agent: * + Disallow: ${urlPrefix} + ''; + + extraServerPath = [ + (pkgs.python+"/bin") + ]; + + options = { + urlPrefix = mkOption { + default = "/hg"; + description = " + The URL prefix under which the Mercurial service appears. + Use the empty string to have it appear in the server root. + "; + }; + + dataDir = mkOption { + example = "/data/mercurial"; + description = " + Path to the directory that holds the repositories. + "; + }; + }; + +}