2 { pkgs, lib, config, ... }:
4 inherit (config) networking;
5 inherit (config.services) gitweb gitolite nginx;
7 gitwebSocket = "/run/gitweb/gitweb.sock";
12 fastcgi_cache_path /var/cache/nginx/fastcgi_cache:${domain}:${srv}
13 keys_zone=${domain}/${srv}:2M
18 virtualHosts."${srv}" = {
19 serverName = "${srv}.${domain}";
20 serverAliases = [ "code.${domain}" ];
24 access_log /var/log/nginx/${domain}/${srv}/access.log json buffer=32k;
25 error_log /var/log/nginx/${domain}/${srv}/error.log warn;
30 include ${pkgs.nginx}/conf/fastcgi_params;
31 ${nginx.configs.https_add_headers}
32 add_header X-Cache $upstream_cache_status;
33 fastcgi_cache ${domain}/${srv};
34 fastcgi_cache_valid 200 1m;
35 fastcgi_cache_valid 404 30m;
36 fastcgi_max_temp_file_size 1M;
37 # Used by gitweb's pathinfo feature
38 fastcgi_param PATH_INFO $fastcgi_script_name;
39 fastcgi_param GITWEB_CONFIG ${gitweb.gitwebConfigFile};
40 fastcgi_pass unix:${gitwebSocket};
44 alias = "${pkgs.gitweb}/static/";
50 root = pkgs.writeTextDir "static-custom/style.css" ''
60 root = pkgs.writeTextDir "robots.txt" ''
63 Disallow: /*/blobdiff/*
64 Disallow: /*/commitdiff/*
65 Disallow: /*/commitdiff_plain/*
68 Disallow: /*/snapshot/*
70 Disallow: /*a=blobdiff*
71 Disallow: /*a=commitdiff*
72 Disallow: /*a=commitdiff_plain*
75 Disallow: /*a=snapshot*
84 systemd.services.nginx.serviceConfig.LogsDirectory = lib.mkForce ["nginx/${domain}/${srv}"];
85 systemd.services.gitweb = {
86 description = "GitWeb FastCGI service";
87 script = "${pkgs.gitweb}/gitweb.cgi --fastcgi --nproc=1";
89 FCGI_SOCKET_PATH = gitwebSocket;
90 FCGI_SOCKET_PERM = "432"; # decimal of 660 in octal, since current CGI::Fast doesn't use perl's oct()
95 RuntimeDirectory = [ "gitweb" ];
99 wantedBy = [ "multi-user.target" ];
103 projectroot = "${gitolite.dataDir}/repositories";
106 my $s = $cgi->https() ? "s" : "";
107 @extra_breadcrumbs = (["sourcephile" => "http''${s}://${domain}"]);
108 $site_name = "Git — Sourcephile";
109 $home_link_str = "git";
110 $projects_list = "${gitolite.dataDir}/projects.list";
111 $projects_list_description_width = 50;
112 $projects_list_group_categories = 1;
113 $default_projects_order = "age";
114 $default_text_plain_charset = 'utf-8';
115 #$fallback_encoding = "utf-8";
117 $export_ok = "git-daemon-export-ok";
120 ( "git://${srv}.${domain}"
121 , "git\@${srv}.${domain}:"
123 # NOTE: more readable URL.
124 $feature{'pathinfo'}{'default'} = [1];
125 @stylesheets = ( "/static/gitweb.css"
126 , "/static-custom/style.css"
128 $logo = "/static/git-logo.png";
129 $favicon = "/static/git-favicon.png";
130 $javascript = "/static/gitweb.js";
131 $feature{'highlight'}{'default'} = [1];