1 {pkgs, lib, config, ...}:
2 let inherit (config) networking;
3 inherit (config.services) gitweb gitolite nginx;
4 package = pkgs.gitweb.override (lib.optionalAttrs gitweb.gitwebTheme {
7 RuntimeDirectory = "gitweb";
8 gitwebSocket = "/run/${RuntimeDirectory}/gitweb.sock";
9 static-custom = pkgs.writeTextFile {
10 name = "static-custom";
11 destination = "/static-custom/style.css";
22 virtualHosts."git" = {
23 serverName = "git.${networking.domain}";
25 map (domainAlias: "git." + domainAlias)
26 config.networking.domainAliases;
28 # { addr = "0.0.0.0"; port = 80; ssl = false; }
34 include ${pkgs.nginx}/conf/fastcgi_params;
35 fastcgi_param PATH_INFO $fastcgi_script_name;
36 # NOTE: used by gitweb's pathinfo feature.
37 fastcgi_param GITWEB_CONFIG ${gitweb.gitwebConfigFile};
38 fastcgi_pass unix:${gitwebSocket};
42 alias = "${pkgs.gitweb}/static/";
45 alias = "${static-custom}/static-custom/";
50 systemd.services.gitweb = {
51 description = "GitWeb FastCGI service";
52 script = "${pkgs.gitweb}/gitweb.cgi --fastcgi --nproc=1";
54 FCGI_SOCKET_PATH = gitwebSocket;
55 FCGI_SOCKET_PERM = "432"; # decimal of 660 in octal, since current CGI::Fast doesn't use perl's oct()
60 RuntimeDirectory = [ RuntimeDirectory ];
64 wantedBy = [ "multi-user.target" ];
68 projectroot = "${gitolite.dataDir}/repositories";
71 my $s = $cgi->https() ? "s" : "";
72 @extra_breadcrumbs = (["${networking.domainBase}" => "http''${s}://${networking.domain}"]);
73 $home_link_str = "git";
74 $projects_list = "${gitolite.dataDir}/projects.list";
75 $projects_list_group_categories = 1;
76 $default_projects_order = "age";
78 $export_ok = "git-daemon-export-ok";
81 ( "git://git.${networking.domain}"
82 , "git\@git.${networking.domain}:"
84 $feature{'pathinfo'}{'default'} = [1];
85 # NOTE: more readable URL.
86 @stylesheets = ( "/static/gitweb.css"
87 , "/static-custom/style.css"
89 $logo = "/static/git-logo.png";
90 $favicon = "/static/git-favicon.png";
91 $javascript = "/static/gitweb.js";
92 $feature{'highlight'}{'default'} = [1];
93 # FIX: gitweb bug: FCGI is not Unicode aware.
95 my $enc = Encode::find_encoding('UTF-8');
96 my $org = \&FCGI::Stream::PRINT;
97 no warnings 'redefine';
98 *FCGI::Stream::PRINT = sub {
100 for (my $i = 1; $i < @_; $i++) {
101 $OUTPUT[$i] = $enc->encode($_[$i], Encode::FB_CROAK|Encode::LEAVE_SRC);