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";
21 virtualHosts."git" = {
22 serverName = "git.${networking.domain}";
24 map (domainAlias: "git." + domainAlias)
25 config.networking.domainAliases;
27 sslCertificate = nginx.virtualHosts."_".sslCertificate;
28 sslCertificateKey = nginx.virtualHosts."_".sslCertificateKey;
32 include ${pkgs.nginx}/conf/fastcgi_params;
33 fastcgi_param PATH_INFO $fastcgi_script_name;
34 # NOTE: used by gitweb's pathinfo feature.
35 fastcgi_param GITWEB_CONFIG ${gitweb.gitwebConfigFile};
36 fastcgi_pass unix:${gitwebSocket};
40 alias = "${pkgs.gitweb}/static/";
43 alias = "${static-custom}/static-custom/";
48 systemd.services.gitweb = {
49 description = "GitWeb FastCGI service";
50 script = "${pkgs.gitweb}/gitweb.cgi --fastcgi --nproc=1";
52 FCGI_SOCKET_PATH = gitwebSocket;
53 FCGI_SOCKET_PERM = "432"; # decimal of 660 in octal, since current CGI::Fast doesn't use perl's oct()
58 RuntimeDirectory = [ RuntimeDirectory ];
62 wantedBy = [ "multi-user.target" ];
66 projectroot = "${gitolite.dataDir}/repositories";
69 my $s = $cgi->https() ? "s" : "";
70 @extra_breadcrumbs = (["${networking.domainBase}" => "http''${s}://${networking.domain}"]);
71 $site_name = "Git — Sourcephile";
72 $home_link_str = "git";
73 $projects_list = "${gitolite.dataDir}/projects.list";
74 $projects_list_group_categories = 1;
75 $default_projects_order = "age";
77 $export_ok = "git-daemon-export-ok";
80 ( "git://git.${networking.domain}"
81 , "git\@git.${networking.domain}:"
83 $feature{'pathinfo'}{'default'} = [1];
84 # NOTE: more readable URL.
85 @stylesheets = ( "/static/gitweb.css"
86 , "/static-custom/style.css"
88 $logo = "/static/git-logo.png";
89 $favicon = "/static/git-favicon.png";
90 $javascript = "/static/gitweb.js";
91 $feature{'highlight'}{'default'} = [1];
92 # FIX: gitweb bug: FCGI is not Unicode aware.
94 my $enc = Encode::find_encoding('UTF-8');
95 my $org = \&FCGI::Stream::PRINT;
96 no warnings 'redefine';
97 *FCGI::Stream::PRINT = sub {
99 for (my $i = 1; $i < @_; $i++) {
100 $OUTPUT[$i] = $enc->encode($_[$i], Encode::FB_CROAK|Encode::LEAVE_SRC);