From dc389c5d1e51c6817eabfcc6f3cc7786214c3489 Mon Sep 17 00:00:00 2001 From: Evgeny Egorochkin Date: Mon, 6 May 2013 13:49:29 +0300 Subject: [PATCH] lighttpd: add gitweb as a sub-service MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Now you can access gitweb at http://yourserver/gitweb by simply adding this to configuration.nix (assuming services.lighttpd.enable = true); services.lighttpd.gitweb.enable = true; The path to all bare repositories served by gitweb can be set with this option (default value below): services.lighttpd.gitweb.projectroot = "/srv/git"; Based on patch contributed by Bjørn Forsman. --- modules/module-list.nix | 1 + .../services/web-servers/lighttpd/gitweb.nix | 63 +++++++++++++++++++ 2 files changed, 64 insertions(+) create mode 100644 modules/services/web-servers/lighttpd/gitweb.nix diff --git a/modules/module-list.nix b/modules/module-list.nix index 60c7909c994..3ce8a6fb969 100644 --- a/modules/module-list.nix +++ b/modules/module-list.nix @@ -186,6 +186,7 @@ ./services/web-servers/apache-httpd/default.nix ./services/web-servers/jboss/default.nix ./services/web-servers/lighttpd/default.nix + ./services/web-servers/lighttpd/gitweb.nix ./services/web-servers/nginx/default.nix ./services/web-servers/tomcat.nix ./services/x11/desktop-managers/default.nix diff --git a/modules/services/web-servers/lighttpd/gitweb.nix b/modules/services/web-servers/lighttpd/gitweb.nix new file mode 100644 index 00000000000..88c63064a04 --- /dev/null +++ b/modules/services/web-servers/lighttpd/gitweb.nix @@ -0,0 +1,63 @@ +{ config, pkgs, ... }: + +with pkgs.lib; + +let + cfg = config.services.lighttpd.gitweb; + gitwebConfigFile = pkgs.writeText "gitweb.conf" '' + # path to git projects (.git) + $projectroot = "${cfg.projectroot}"; + ''; +in +{ + + options.services.lighttpd.gitweb = { + + enable = mkOption { + default = false; + type = types.uniq types.bool; + description = '' + If true, enable gitweb in lighttpd. Access it at http://yourserver/gitweb + ''; + }; + + projectroot = mkOption { + default = "/srv/git"; + type = types.uniq types.string; + description = '' + Path to git projects (bare repositories) that should be served by + gitweb. Must not end with a slash. + ''; + }; + + }; + + config = mkIf cfg.enable { + + services.lighttpd.extraConfig = '' + server.modules += ( + "mod_alias", + "mod_cgi", + "mod_redirect", + "mod_setenv" + ) + $HTTP["url"] =~ "^/gitweb" { + cgi.assign = ( + ".cgi" => "${pkgs.perl}/bin/perl" + ) + url.redirect = ( + "^/gitweb$" => "/gitweb/" + ) + alias.url = ( + "/gitweb/static/" => "${pkgs.git}/share/gitweb/static/", + "/gitweb/" => "${pkgs.git}/share/gitweb/gitweb.cgi" + ) + setenv.add-environment = ( + "GITWEB_CONFIG" => "${gitwebConfigFile}" + ) + } + ''; + + }; + +}