1 { pkgs, lib, config, ... }:
2 let inherit (config) networking;
3 inherit (config.services) gitweb gitolite nginx;
4 domain = "sourcephile.fr";
5 package = pkgs.gitweb.override (lib.optionalAttrs gitweb.gitwebTheme {
8 RuntimeDirectory = "gitweb";
9 gitwebSocket = "/run/${RuntimeDirectory}/gitweb.sock";
10 static-custom = pkgs.writeTextFile {
11 name = "static-custom";
12 destination = "/static-custom/style.css";
22 virtualHosts."git" = {
23 serverName = "git.${domain}";
25 map (domainAlias: "git." + domainAlias)
26 config.networking.domainAliases;
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/";
46 root = pkgs.writeTextDir "robots.txt" ''
49 Disallow: /*/blobdiff/*
50 Disallow: /*/commitdiff/*
52 Disallow: /*/snapshot/*
62 systemd.services.gitweb = {
63 description = "GitWeb FastCGI service";
64 script = "${pkgs.gitweb}/gitweb.cgi --fastcgi --nproc=1";
66 FCGI_SOCKET_PATH = gitwebSocket;
67 FCGI_SOCKET_PERM = "432"; # decimal of 660 in octal, since current CGI::Fast doesn't use perl's oct()
72 RuntimeDirectory = [ RuntimeDirectory ];
76 wantedBy = [ "multi-user.target" ];
80 projectroot = "${gitolite.dataDir}/repositories";
83 my $s = $cgi->https() ? "s" : "";
84 @extra_breadcrumbs = (["${networking.domainBase}" => "http''${s}://${domain}"]);
85 $site_name = "Git — Sourcephile";
86 $home_link_str = "git";
87 $projects_list = "${gitolite.dataDir}/projects.list";
88 $projects_list_description_width = 50;
89 $projects_list_group_categories = 1;
90 $default_projects_order = "age";
92 $export_ok = "git-daemon-export-ok";
95 ( "git://git.${domain}"
96 , "git\@git.${domain}:"
98 # NOTE: more readable URL.
99 $feature{'pathinfo'}{'default'} = [1];
100 @stylesheets = ( "/static/gitweb.css"
101 , "/static-custom/style.css"
103 $logo = "/static/git-logo.png";
104 $favicon = "/static/git-favicon.png";
105 $javascript = "/static/gitweb.js";
106 $feature{'highlight'}{'default'} = [1];
107 # FIX: gitweb bug: FCGI is not Unicode aware.
108 if ($first_request) {
109 my $enc = Encode::find_encoding('UTF-8');
110 my $org = \&FCGI::Stream::PRINT;
111 no warnings 'redefine';
112 *FCGI::Stream::PRINT = sub {
114 for (my $i = 1; $i < @_; $i++) {
115 $OUTPUT[$i] = $enc->encode($_[$i], Encode::FB_CROAK|Encode::LEAVE_SRC);