]> git.immae.eu Git - perso/Immae/Config/Nix.git/commitdiff
Add cgit to replace gitweb
authorIsmaël Bouya <ismael.bouya@normalesup.org>
Tue, 19 Jan 2021 21:28:04 +0000 (22:28 +0100)
committerIsmaël Bouya <ismael.bouya@normalesup.org>
Tue, 19 Jan 2021 21:28:04 +0000 (22:28 +0100)
modules/private/monitoring/objects_monitoring-1.nix
modules/private/websites/tools/git/gitweb.nix

index 4b784eddbbf984689e7b0272ca90aa6354d2b602..468785046dcbc89a96fdfe3bb1e514a8944785f0 100644 (file)
@@ -495,7 +495,7 @@ in
       service_description = "gitweb website is running on git.immae.eu";
       host_name = "eldiron.immae.eu";
       use = "external-web-service";
-      check_command = ["check_https" "git.immae.eu" "/" "git web interface"];
+      check_command = ["check_https" "git.immae.eu" "/cgit" "<title>Immae’s git"];
 
       servicegroups = "webstatus-webapps";
       _webstatus_name = "Git";
index 2ee7a63a5b804b34684102271a7a3a7f2819a98e..dab0c9eaf1f6f677ece4d394c3eec9190fd4cf23 100644 (file)
@@ -1,4 +1,4 @@
-{ gitweb, writeText, gitolite, git, gitoliteDir, highlight }:
+{ gitweb, writeText, stdenv, coreutils, writeScript, gitolite, git, cgit, gitoliteDir, mailcap, highlight }:
 rec {
   varDir = gitoliteDir;
   webRoot = gitweb;
@@ -29,6 +29,50 @@ rec {
     $project_list_default_category = "__Others__";
     $highlight_bin = "${highlight}/bin/highlight";
     '';
+  aboutFilter = writeScript "about-filter.sh" ''
+    #!${stdenv.shell}
+
+    if [ -f "$CGIT_REPO_PATH/README.html" ]; then
+      cat "$CGIT_REPO_PATH/README.html"
+    else
+      ${cgit}/lib/cgit/filters/about-formatting.sh "$@"
+    fi
+  '';
+  cgitConfig = writeText "cgitrc" ''
+    css=/cgit-css/cgit.css
+    logo=/cgit-css/cgit.png
+    favicon=/cgit-css/favicon.ico
+
+    root-title=Immae’s git
+    root-desc=To go back to the old interface: https://git.immae.eu/?old
+    readme=:README.md
+    readme=:readme.md
+    readme=:README
+    readme=:DOCUMENTATION.md
+    about-filter=${aboutFilter}
+    #${cgit}/lib/cgit/filters/about-formatting.sh
+    source-filter=${cgit}/lib/cgit/filters/syntax-highlighting.py
+
+    enable-blame=1
+    enable-index-links=1
+    enable-commit-graph=1
+    enable-log-filecount=1
+    enable-log-linecount=1
+
+    enable-html-serving=1
+    # Allow using gitweb.* keys
+    enable-git-config=1
+
+    side-by-side-diffs=1
+    snapshots=tar.gz tar.zst zip
+    mimetype-file=${mailcap}/etc/mime.types
+
+    section=__Others__
+    clone-url=ssh://gitolite@git.immae.eu/$CGIT_REPO_URL https://git.immae.eu/$CGIT_REPO_URL
+    #section-from-path=1
+    project-list=${varDir}/projects.list
+    scan-path=${varDir}/repositories
+    '';
   apache = rec {
     user = "wwwrun";
     group = "wwwrun";
@@ -59,6 +103,19 @@ rec {
           SetEnv  GITWEB_CONFIG  "${config}"
         </Files>
       </Directory>
+
+      SetEnv CGIT_CONFIG ${cgitConfig}
+      ScriptAlias /cgit "${cgit}/cgit/cgit.cgi/"
+      Alias /cgit-css "${cgit}/cgit"
+      <Directory "${cgit}/cgit/">
+        AllowOverride None
+        Options ExecCGI FollowSymlinks
+        Require all granted
+      </Directory>
+
+      RewriteEngine On
+      RewriteCond %{QUERY_STRING} ^$
+      RewriteRule ^/?$ /cgit [L,R=302]
       '';
   };
 }