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