]> git.immae.eu Git - perso/Immae/Config/Nix.git/blame - modules/private/websites/tools/git/gitweb.nix
Add cgit to replace gitweb
[perso/Immae/Config/Nix.git] / modules / private / websites / tools / git / gitweb.nix
CommitLineData
d60c4da1 1{ gitweb, writeText, stdenv, coreutils, writeScript, gitolite, git, cgit, gitoliteDir, mailcap, highlight }:
5c101474 2rec {
950ca5ee 3 varDir = gitoliteDir;
5c101474
IB
4 webRoot = gitweb;
5 config = writeText "gitweb.conf" ''
6 $git_temp = "/tmp";
cf80b4f2 7
5c101474
IB
8 # The directories where your projects are. Must not end with a
9 # slash.
10 $projectroot = "${varDir}/repositories";
cf80b4f2 11
5c101474
IB
12 $projects_list = "${varDir}/projects.list";
13 $strict_export = "true";
cf80b4f2 14
5c101474
IB
15 # Base URLs for links displayed in the web interface.
16 our @git_base_url_list = qw(ssh://gitolite@git.immae.eu https://git.immae.eu);
cf80b4f2 17
5c101474
IB
18 $feature{'blame'}{'default'} = [1];
19 $feature{'avatar'}{'default'} = ['gravatar'];
20 $feature{'highlight'}{'default'} = [1];
cf80b4f2 21
5c101474
IB
22 @stylesheets = ("gitweb-theme/gitweb.css");
23 $logo = "gitweb-theme/git-logo.png";
24 $favicon = "gitweb-theme/git-favicon.png";
25 $javascript = "gitweb-theme/gitweb.js";
26 $logo_url = "https://git.immae.eu/";
27 $projects_list_group_categories = "true";
28 $projects_list_description_width = 60;
29 $project_list_default_category = "__Others__";
e570c4f5 30 $highlight_bin = "${highlight}/bin/highlight";
5c101474 31 '';
d60c4da1
IB
32 aboutFilter = writeScript "about-filter.sh" ''
33 #!${stdenv.shell}
34
35 if [ -f "$CGIT_REPO_PATH/README.html" ]; then
36 cat "$CGIT_REPO_PATH/README.html"
37 else
38 ${cgit}/lib/cgit/filters/about-formatting.sh "$@"
39 fi
40 '';
41 cgitConfig = writeText "cgitrc" ''
42 css=/cgit-css/cgit.css
43 logo=/cgit-css/cgit.png
44 favicon=/cgit-css/favicon.ico
45
46 root-title=Immae’s git
47 root-desc=To go back to the old interface: https://git.immae.eu/?old
48 readme=:README.md
49 readme=:readme.md
50 readme=:README
51 readme=:DOCUMENTATION.md
52 about-filter=${aboutFilter}
53 #${cgit}/lib/cgit/filters/about-formatting.sh
54 source-filter=${cgit}/lib/cgit/filters/syntax-highlighting.py
55
56 enable-blame=1
57 enable-index-links=1
58 enable-commit-graph=1
59 enable-log-filecount=1
60 enable-log-linecount=1
61
62 enable-html-serving=1
63 # Allow using gitweb.* keys
64 enable-git-config=1
65
66 side-by-side-diffs=1
67 snapshots=tar.gz tar.zst zip
68 mimetype-file=${mailcap}/etc/mime.types
69
70 section=__Others__
71 clone-url=ssh://gitolite@git.immae.eu/$CGIT_REPO_URL https://git.immae.eu/$CGIT_REPO_URL
72 #section-from-path=1
73 project-list=${varDir}/projects.list
74 scan-path=${varDir}/repositories
75 '';
a95ab089 76 apache = rec {
5c101474
IB
77 user = "wwwrun";
78 group = "wwwrun";
79 modules = [ "cgid" ];
a95ab089
IB
80 webappName = "tools_gitweb";
81 root = "/run/current-system/webapps/${webappName}";
5c101474
IB
82 vhostConf = ''
83 SetEnv GIT_PROJECT_ROOT ${varDir}/repositories/
84 ScriptAliasMatch \
85 "(?x)^/(.*/(HEAD | \
86 info/refs | \
87 objects/(info/[^/]+ | \
88 [0-9a-f]{2}/[0-9a-f]{38} | \
89 pack/pack-[0-9a-f]{40}\.(pack|idx)) | \
90 git-(upload|receive)-pack))$" \
91 ${git}/libexec/git-core/git-http-backend/$1
cf80b4f2 92
5c101474
IB
93 <Directory "${git}/libexec/git-core">
94 Require all granted
95 </Directory>
a95ab089 96 <Directory "${root}">
5c101474
IB
97 DirectoryIndex gitweb.cgi
98 Require all granted
99 AllowOverride None
100 Options ExecCGI FollowSymLinks
101 <Files gitweb.cgi>
102 SetHandler cgi-script
103 SetEnv GITWEB_CONFIG "${config}"
104 </Files>
105 </Directory>
d60c4da1
IB
106
107 SetEnv CGIT_CONFIG ${cgitConfig}
108 ScriptAlias /cgit "${cgit}/cgit/cgit.cgi/"
109 Alias /cgit-css "${cgit}/cgit"
110 <Directory "${cgit}/cgit/">
111 AllowOverride None
112 Options ExecCGI FollowSymlinks
113 Require all granted
114 </Directory>
115
116 RewriteEngine On
117 RewriteCond %{QUERY_STRING} ^$
118 RewriteRule ^/?$ /cgit [L,R=302]
5c101474 119 '';
cf80b4f2 120 };
5c101474 121}