1{
2 config,
3 lib,
4 pkgs,
5 ...
6}:
7
8with lib;
9
10let
11 cfg = config.services.gitweb;
12 package = pkgs.gitweb.override (
13 optionalAttrs cfg.gitwebTheme {
14 gitwebTheme = true;
15 }
16 );
17
18in
19{
20
21 options.services.lighttpd.gitweb = {
22
23 enable = mkOption {
24 default = false;
25 type = types.bool;
26 description = ''
27 If true, enable gitweb in lighttpd. Access it at http://yourserver/gitweb
28 '';
29 };
30
31 };
32
33 config = mkIf config.services.lighttpd.gitweb.enable {
34
35 # declare module dependencies
36 services.lighttpd.enableModules = [
37 "mod_cgi"
38 "mod_redirect"
39 "mod_alias"
40 "mod_setenv"
41 ];
42
43 services.lighttpd.extraConfig = ''
44 $HTTP["url"] =~ "^/gitweb" {
45 cgi.assign = (
46 ".cgi" => "${pkgs.perl}/bin/perl"
47 )
48 url.redirect = (
49 "^/gitweb$" => "/gitweb/"
50 )
51 alias.url = (
52 "/gitweb/static/" => "${package}/static/",
53 "/gitweb/" => "${package}/gitweb.cgi"
54 )
55 setenv.add-environment = (
56 "GITWEB_CONFIG" => "${cfg.gitwebConfigFile}",
57 "HOME" => "${cfg.projectroot}"
58 )
59 }
60 '';
61
62 };
63
64}