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;
33 include ${pkgs.nginx}/conf/fastcgi_params;
34 fastcgi_param PATH_INFO $fastcgi_script_name;
35 # NOTE: used by gitweb's pathinfo feature.
36 fastcgi_param GITWEB_CONFIG ${gitweb.gitwebConfigFile};
37 fastcgi_pass unix:${gitwebSocket};
41 alias = "${pkgs.gitweb}/static/";
44 alias = "${static-custom}/static-custom/";
49 systemd.services.gitweb = {
50 description = "GitWeb FastCGI service";
51 script = "${pkgs.gitweb}/gitweb.cgi --fastcgi --nproc=1";
53 FCGI_SOCKET_PATH = gitwebSocket;
54 FCGI_SOCKET_PERM = "432"; # decimal of 660 in octal, since current CGI::Fast doesn't use perl's oct()
59 RuntimeDirectory = [ RuntimeDirectory ];
63 wantedBy = [ "multi-user.target" ];
67 projectroot = "${gitolite.dataDir}/repositories";
70 my $s = $cgi->https() ? "s" : "";
71 @extra_breadcrumbs = (["${networking.domainBase}" => "http''${s}://${domain}"]);
72 $site_name = "Git — Sourcephile";
73 $home_link_str = "git";
74 $projects_list = "${gitolite.dataDir}/projects.list";
75 $projects_list_description_width = 50;
76 $projects_list_group_categories = 1;
77 $default_projects_order = "age";
79 $export_ok = "git-daemon-export-ok";
82 ( "git://git.${domain}"
83 , "git\@git.${domain}:"
85 # NOTE: more readable URL.
86 $feature{'pathinfo'}{'default'} = [1];
87 @stylesheets = ( "/static/gitweb.css"
88 , "/static-custom/style.css"
90 $logo = "/static/git-logo.png";
91 $favicon = "/static/git-favicon.png";
92 $javascript = "/static/gitweb.js";
93 $feature{'highlight'}{'default'} = [1];
94 # FIX: gitweb bug: FCGI is not Unicode aware.
96 my $enc = Encode::find_encoding('UTF-8');
97 my $org = \&FCGI::Stream::PRINT;
98 no warnings 'redefine';
99 *FCGI::Stream::PRINT = sub {
101 for (my $i = 1; $i < @_; $i++) {
102 $OUTPUT[$i] = $enc->encode($_[$i], Encode::FB_CROAK|Encode::LEAVE_SRC);