1 {pkgs, lib, config, ...}:
2 let inherit (config.services) gitweb gitolite nginx;
3 package = pkgs.gitweb.override (lib.optionalAttrs gitweb.gitwebTheme {
6 RuntimeDirectory = "gitweb";
7 gitwebSocket = "/run/${RuntimeDirectory}/gitweb.sock";
12 virtualHosts."git" = {
13 serverName = "git.${config.networking.domain}";
15 # { addr = "0.0.0.0"; port = 80; ssl = false; }
21 include ${pkgs.nginx}/conf/fastcgi_params;
22 fastcgi_param PATH_INFO $fastcgi_script_name;
23 # NOTE: used by gitweb's pathinfo feature.
24 fastcgi_param GITWEB_CONFIG ${gitweb.gitwebConfigFile};
25 fastcgi_pass unix:${gitwebSocket};
29 alias = "${pkgs.gitweb}/static/";
34 systemd.services.gitweb = {
35 description = "GitWeb FastCGI service";
36 script = "${pkgs.gitweb}/gitweb.cgi --fastcgi --nproc=1";
38 FCGI_SOCKET_PATH = gitwebSocket;
39 FCGI_SOCKET_PERM = "432"; # decimal of 660 in octal, since current CGI::Fast doesn't use perl's oct()
44 RuntimeDirectory = [ RuntimeDirectory ];
48 wantedBy = [ "multi-user.target" ];
52 projectroot = "${gitolite.dataDir}/repositories";
55 my $s = $cgi->https() ? "s" : "";
56 @extra_breadcrumbs = (["commonsoft" => "http''${s}://commonsoft.coop"]);
57 $home_link_str = "git";
58 $projects_list = "${gitolite.dataDir}/projects.list";
59 $projects_list_group_categories = 1;
60 $default_projects_order = "age";
62 $export_ok = "git-daemon-export-ok";
65 ( "git://git.${config.networking.domain}"
66 , "git\@git.${config.networking.domain}:"
68 $feature{'pathinfo'}{'default'} = [1];
69 # NOTE: more readable URL.
70 @stylesheets = ("/static/gitweb.css");
71 $logo = "/static/git-logo.png";
72 $favicon = "/static/git-favicon.png";
73 $javascript = "/static/gitweb.js";
74 $feature{'highlight'}{'default'} = [1];
75 # FIX: gitweb bug: FCGI is not Unicode aware.
77 my $enc = Encode::find_encoding('UTF-8');
78 my $org = \&FCGI::Stream::PRINT;
79 no warnings 'redefine';
80 *FCGI::Stream::PRINT = sub {
82 for (my $i = 1; $i < @_; $i++) {
83 $OUTPUT[$i] = $enc->encode($_[$i], Encode::FB_CROAK|Encode::LEAVE_SRC);