1 { pkgs, lib, config, ... }:
3 inherit (config) networking;
4 inherit (config.services) gitweb gitolite nginx;
5 domain = "sourcephile.fr";
7 gitwebSocket = "/run/gitweb/gitweb.sock";
11 virtualHosts."${srv}" = {
12 serverName = "${srv}.${domain}";
16 access_log ${nginx.logDir}/${domain}/${srv}/access.log json buffer=32k;
17 error_log ${nginx.logDir}/${domain}/${srv}/error.log warn;
22 include ${pkgs.nginx}/conf/fastcgi_params;
23 fastcgi_param PATH_INFO $fastcgi_script_name;
24 # NOTE: used by gitweb's pathinfo feature.
25 fastcgi_param GITWEB_CONFIG ${gitweb.gitwebConfigFile};
26 fastcgi_pass unix:${gitwebSocket};
30 alias = "${pkgs.gitweb}/static/";
36 root = pkgs.writeTextDir "style.css" ''
46 root = pkgs.writeTextDir "robots.txt" ''
49 Disallow: /*/blobdiff/*
50 Disallow: /*/commitdiff/*
52 Disallow: /*/snapshot/*
61 systemd.services.nginx.preStart = lib.mkBefore ''
62 install -D -d -m 750 -o ${nginx.user} -g ${nginx.group} ${nginx.logDir}/${domain}/${srv}/
64 systemd.services.gitweb = {
65 description = "GitWeb FastCGI service";
66 script = "${pkgs.gitweb}/gitweb.cgi --fastcgi --nproc=1";
68 FCGI_SOCKET_PATH = gitwebSocket;
69 FCGI_SOCKET_PERM = "432"; # decimal of 660 in octal, since current CGI::Fast doesn't use perl's oct()
74 RuntimeDirectory = [ "gitweb" ];
78 wantedBy = [ "multi-user.target" ];
82 projectroot = "${gitolite.dataDir}/repositories";
85 my $s = $cgi->https() ? "s" : "";
86 @extra_breadcrumbs = (["${networking.domainBase}" => "http''${s}://${domain}"]);
87 $site_name = "Git — Sourcephile";
88 $home_link_str = "git";
89 $projects_list = "${gitolite.dataDir}/projects.list";
90 $projects_list_description_width = 50;
91 $projects_list_group_categories = 1;
92 $default_projects_order = "age";
94 $export_ok = "git-daemon-export-ok";
97 ( "git://${srv}.${domain}"
98 , "git\@${srv}.${domain}:"
100 # NOTE: more readable URL.
101 $feature{'pathinfo'}{'default'} = [1];
102 @stylesheets = ( "/static/gitweb.css"
103 , "/static-custom/style.css"
105 $logo = "/static/git-logo.png";
106 $favicon = "/static/git-favicon.png";
107 $javascript = "/static/gitweb.js";
108 $feature{'highlight'}{'default'} = [1];
109 # FIX: gitweb bug: FCGI is not Unicode aware.
110 if ($first_request) {
111 my $enc = Encode::find_encoding('UTF-8');
112 my $org = \&FCGI::Stream::PRINT;
113 no warnings 'redefine';
114 *FCGI::Stream::PRINT = sub {
116 for (my $i = 1; $i < @_; $i++) {
117 $OUTPUT[$i] = $enc->encode($_[$i], Encode::FB_CROAK|Encode::LEAVE_SRC);