2014-04-14 15:26:48 +01:00
|
|
|
{ config, lib, pkgs, ... }:
|
2013-05-06 11:49:29 +01:00
|
|
|
|
2014-04-14 15:26:48 +01:00
|
|
|
with lib;
|
2013-05-06 11:49:29 +01:00
|
|
|
|
|
|
|
let
|
|
|
|
cfg = config.services.lighttpd.gitweb;
|
|
|
|
gitwebConfigFile = pkgs.writeText "gitweb.conf" ''
|
|
|
|
# path to git projects (<project>.git)
|
|
|
|
$projectroot = "${cfg.projectroot}";
|
2013-06-02 18:26:55 +01:00
|
|
|
${cfg.extraConfig}
|
2013-05-06 11:49:29 +01:00
|
|
|
'';
|
2013-06-02 18:26:55 +01:00
|
|
|
|
2013-05-06 11:49:29 +01:00
|
|
|
in
|
|
|
|
{
|
|
|
|
|
|
|
|
options.services.lighttpd.gitweb = {
|
|
|
|
|
|
|
|
enable = mkOption {
|
|
|
|
default = false;
|
2015-06-15 17:10:26 +01:00
|
|
|
type = types.bool;
|
2013-05-06 11:49:29 +01:00
|
|
|
description = ''
|
|
|
|
If true, enable gitweb in lighttpd. Access it at http://yourserver/gitweb
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
projectroot = mkOption {
|
|
|
|
default = "/srv/git";
|
2014-07-23 21:18:37 +01:00
|
|
|
type = types.path;
|
2013-05-06 11:49:29 +01:00
|
|
|
description = ''
|
|
|
|
Path to git projects (bare repositories) that should be served by
|
|
|
|
gitweb. Must not end with a slash.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2013-06-02 18:26:55 +01:00
|
|
|
extraConfig = mkOption {
|
|
|
|
default = "";
|
2014-07-23 21:18:37 +01:00
|
|
|
type = types.lines;
|
2013-06-02 18:26:55 +01:00
|
|
|
description = ''
|
|
|
|
Verbatim configuration text appended to the generated gitweb.conf file.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2013-05-06 11:49:29 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
|
2014-09-07 15:47:49 +01:00
|
|
|
# declare module dependencies
|
|
|
|
services.lighttpd.enableModules = [ "mod_cgi" "mod_redirect" "mod_alias" "mod_setenv" ];
|
|
|
|
|
2013-05-06 11:49:29 +01:00
|
|
|
services.lighttpd.extraConfig = ''
|
|
|
|
$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 = (
|
2017-04-11 21:45:41 +01:00
|
|
|
"GITWEB_CONFIG" => "${gitwebConfigFile}",
|
|
|
|
"HOME" => "${cfg.projectroot}"
|
2013-05-06 11:49:29 +01:00
|
|
|
)
|
|
|
|
}
|
|
|
|
'';
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|