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}.${domain}" = {
22 access_log /var/log/nginx/${domain}/${srv}/access.log json buffer=32k;
23 error_log /var/log/nginx/${domain}/${srv}/error.log warn;
28 include ${pkgs.nginx}/conf/fastcgi_params;
29 ${nginx.configs.https_add_headers}
30 add_header X-Cache $upstream_cache_status;
31 fastcgi_cache ${domain}/${srv};
32 fastcgi_cache_valid 200 1m;
33 fastcgi_cache_valid 404 3m;
34 fastcgi_max_temp_file_size 1M;
35 # Used by gitweb's pathinfo feature
36 fastcgi_param PATH_INFO $fastcgi_script_name;
37 fastcgi_param GITWEB_CONFIG ${gitweb.gitwebConfigFile};
38 fastcgi_pass unix:${gitwebSocket};
42 alias = "${pkgs.gitweb}/static/";
48 root = pkgs.writeTextDir "static-custom/style.css" ''
58 root = pkgs.writeTextDir "robots.txt" ''
61 Disallow: /*/blobdiff/*
62 Disallow: /*/commitdiff/*
63 Disallow: /*/commitdiff_plain/*
66 Disallow: /*/snapshot/*
68 Disallow: /*a=blobdiff*
69 Disallow: /*a=commitdiff*
70 Disallow: /*a=commitdiff_plain*
73 Disallow: /*a=snapshot*
82 systemd.services.nginx.serviceConfig.LogsDirectory = lib.mkForce ["nginx/${domain}/${srv}"];
83 systemd.services.gitweb = {
84 description = "GitWeb FastCGI service";
85 script = "${pkgs.gitweb}/gitweb.cgi --fastcgi --nproc=1";
87 FCGI_SOCKET_PATH = gitwebSocket;
88 FCGI_SOCKET_PERM = "432"; # decimal of 660 in octal, since current CGI::Fast doesn't use perl's oct()
93 RuntimeDirectory = [ "gitweb" ];
97 wantedBy = [ "multi-user.target" ];
101 projectroot = "${gitolite.dataDir}/repositories";
104 my $s = $cgi->https() ? "s" : "";
105 @extra_breadcrumbs = (["sourcephile" => "http''${s}://${domain}"]);
106 $site_name = "Git — Sourcephile";
107 $home_link_str = "git";
108 $projects_list = "${gitolite.dataDir}/projects.list";
109 $projects_list_description_width = 50;
110 $projects_list_group_categories = 1;
111 $default_projects_order = "age";
112 $default_text_plain_charset = 'utf-8';
113 #$fallback_encoding = "utf-8";
115 $export_ok = "git-daemon-export-ok";
118 ( "git://${srv}.${domain}"
119 , "git\@${srv}.${domain}:"
121 # NOTE: more readable URL.
122 $feature{'pathinfo'}{'default'} = [1];
123 @stylesheets = ( "/static/gitweb.css"
124 , "/static-custom/style.css"
126 $logo = "/static/git-logo.png";
127 $favicon = "/static/git-favicon.png";
128 $javascript = "/static/gitweb.js";
129 $feature{'highlight'}{'default'} = [1];