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";
8 static-custom = pkgs.writeTextFile {
9 name = "static-custom";
10 destination = "/static-custom/style.css";
21 virtualHosts."git" = {
22 serverName = "git.${config.networking.domain}";
24 # { addr = "0.0.0.0"; port = 80; ssl = false; }
30 include ${pkgs.nginx}/conf/fastcgi_params;
31 fastcgi_param PATH_INFO $fastcgi_script_name;
32 # NOTE: used by gitweb's pathinfo feature.
33 fastcgi_param GITWEB_CONFIG ${gitweb.gitwebConfigFile};
34 fastcgi_pass unix:${gitwebSocket};
38 alias = "${pkgs.gitweb}/static/";
41 alias = "${static-custom}/static-custom/";
46 systemd.services.gitweb = {
47 description = "GitWeb FastCGI service";
48 script = "${pkgs.gitweb}/gitweb.cgi --fastcgi --nproc=1";
50 FCGI_SOCKET_PATH = gitwebSocket;
51 FCGI_SOCKET_PERM = "432"; # decimal of 660 in octal, since current CGI::Fast doesn't use perl's oct()
56 RuntimeDirectory = [ RuntimeDirectory ];
60 wantedBy = [ "multi-user.target" ];
64 projectroot = "${gitolite.dataDir}/repositories";
67 my $s = $cgi->https() ? "s" : "";
68 @extra_breadcrumbs = (["${config.networking.baseName}" => "http''${s}://${config.networking.domain}"]);
69 $home_link_str = "git";
70 $projects_list = "${gitolite.dataDir}/projects.list";
71 $projects_list_group_categories = 1;
72 $default_projects_order = "age";
74 $export_ok = "git-daemon-export-ok";
77 ( "git://git.${config.networking.domain}"
78 , "git\@git.${config.networking.domain}:"
80 $feature{'pathinfo'}{'default'} = [1];
81 # NOTE: more readable URL.
82 @stylesheets = ( "/static/gitweb.css"
83 , "/static-custom/style.css"
85 $logo = "/static/git-logo.png";
86 $favicon = "/static/git-favicon.png";
87 $javascript = "/static/gitweb.js";
88 $feature{'highlight'}{'default'} = [1];
89 # FIX: gitweb bug: FCGI is not Unicode aware.
91 my $enc = Encode::find_encoding('UTF-8');
92 my $org = \&FCGI::Stream::PRINT;
93 no warnings 'redefine';
94 *FCGI::Stream::PRINT = sub {
96 for (my $i = 1; $i < @_; $i++) {
97 $OUTPUT[$i] = $enc->encode($_[$i], Encode::FB_CROAK|Encode::LEAVE_SRC);