aboutsummaryrefslogtreecommitdiff
path: root/systems/eldiron/websites/git/gitweb.nix
diff options
context:
space:
mode:
Diffstat (limited to 'systems/eldiron/websites/git/gitweb.nix')
-rw-r--r--systems/eldiron/websites/git/gitweb.nix124
1 files changed, 124 insertions, 0 deletions
diff --git a/systems/eldiron/websites/git/gitweb.nix b/systems/eldiron/websites/git/gitweb.nix
new file mode 100644
index 0000000..40f99e0
--- /dev/null
+++ b/systems/eldiron/websites/git/gitweb.nix
@@ -0,0 +1,124 @@
1{ gitweb, writeText, stdenv, coreutils, writeScript, gitolite, git, cgit, gitoliteDir, mailcap, highlight }:
2rec {
3 varDir = gitoliteDir;
4 config = writeText "gitweb.conf" ''
5 $git_temp = "/tmp";
6
7 # The directories where your projects are. Must not end with a
8 # slash.
9 $projectroot = "${varDir}/repositories";
10
11 $projects_list = "${varDir}/projects.list";
12 $strict_export = "true";
13
14 # Base URLs for links displayed in the web interface.
15 our @git_base_url_list = qw(ssh://gitolite@git.immae.eu https://git.immae.eu);
16
17 $feature{'blame'}{'default'} = [1];
18 $feature{'avatar'}{'default'} = ['gravatar'];
19 $feature{'highlight'}{'default'} = [1];
20
21 @stylesheets = ("gitweb-theme/gitweb.css");
22 $logo = "gitweb-theme/git-logo.png";
23 $favicon = "gitweb-theme/git-favicon.png";
24 $javascript = "gitweb-theme/gitweb.js";
25 $logo_url = "https://git.immae.eu/";
26 $projects_list_group_categories = "true";
27 $projects_list_description_width = 60;
28 $project_list_default_category = "__Others__";
29 $highlight_bin = "${highlight}/bin/highlight";
30 '';
31 aboutFilter = writeScript "about-filter.sh" ''
32 #!${stdenv.shell}
33
34 if [ -f "$CGIT_REPO_PATH/README.html" ]; then
35 cat "$CGIT_REPO_PATH/README.html"
36 else
37 ${cgit}/lib/cgit/filters/about-formatting.sh "$@"
38 fi
39 '';
40 cgitConfig = writeText "cgitrc" ''
41 css=/cgit-css/cgit.css
42 logo=/cgit-css/cgit.png
43 favicon=/cgit-css/favicon.ico
44 head-include=${./cgit_js.html}
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 '';
76 apache = rec {
77 user = "wwwrun";
78 group = "wwwrun";
79 modules = [ "cgid" ];
80 root = gitweb;
81 vhostConf = ''
82 SetEnv GIT_PROJECT_ROOT ${varDir}/repositories/
83 ScriptAliasMatch \
84 "(?x)^/(.*/(HEAD | \
85 info/refs | \
86 objects/(info/[^/]+ | \
87 [0-9a-f]{2}/[0-9a-f]{38} | \
88 pack/pack-[0-9a-f]{40}\.(pack|idx)) | \
89 git-(upload|receive)-pack))$" \
90 ${git}/libexec/git-core/git-http-backend/$1
91
92 <Directory "${git}/libexec/git-core">
93 Require all granted
94 </Directory>
95 <Directory "${root}">
96 DirectoryIndex gitweb.cgi
97 Require all granted
98 AllowOverride None
99 Options ExecCGI FollowSymLinks
100 <Files gitweb.cgi>
101 SetHandler cgi-script
102 SetEnv GITWEB_CONFIG "${config}"
103 </Files>
104 </Directory>
105
106 SetEnv CGIT_CONFIG ${cgitConfig}
107 ScriptAlias /cgit "${cgit}/cgit/cgit.cgi/"
108 Alias /cgit-css "${cgit}/cgit"
109 <Directory "${cgit}/cgit/">
110 AllowOverride None
111 Options ExecCGI FollowSymlinks
112 Require all granted
113 </Directory>
114
115 RewriteEngine On
116 RewriteCond %{QUERY_STRING} ^$
117 RewriteRule ^/?$ /cgit [L,R=302]
118
119 RewriteCond %{REQUEST_URI} ^(.*)(\.git)?/?$
120 RewriteCond ${varDir}/repositories/%1.git/HEAD -f
121 RewriteRule ^(.+)$ /cgit$1 [L,R=302]
122 '';
123 };
124}