summary refs log tree commit diff
path: root/fleet/hosts/trieste/cgit/default.nix
diff options
context:
space:
mode:
Diffstat (limited to 'fleet/hosts/trieste/cgit/default.nix')
-rw-r--r--fleet/hosts/trieste/cgit/default.nix47
1 files changed, 20 insertions, 27 deletions
diff --git a/fleet/hosts/trieste/cgit/default.nix b/fleet/hosts/trieste/cgit/default.nix
index 34268e6..e80b275 100644
--- a/fleet/hosts/trieste/cgit/default.nix
+++ b/fleet/hosts/trieste/cgit/default.nix
@@ -7,7 +7,11 @@
 with lib;
 
 let
-  cgit-package = pkgs.cgit-pink;
+  cgit-package = pkgs.cgit-pink.overrideAttrs ({ patches ? [], ... }: {
+    patches = patches ++ [
+      ./monorepo-support.patch
+    ];
+  });
 
   cgit-webroot = pkgs.runCommand "cgit-webroot" {
     extraStyles = ''
@@ -26,7 +30,6 @@ let
     ${pkgs.minify}/bin/minify --type css --bundle ${cgit-package}/cgit/cgit.css $extraStylesPath -o $out/cgit.css
     cp ${./un.svg} $out/un.svg  # TODO(V): remove this variant, apply padding to the Sigil using CSS
     cp ${./unicon.svg} $out/unicon.svg  # This is the same as un.svg, but without any padding
-    cp ${./ripple.svg} $out/ripple.svg  # This is referenced in git.nix (as config.cgit.logo, for Ripple)
     cp ${cgit-package}/cgit/robots.txt $out
   '';
 
@@ -41,31 +44,23 @@ let
     # TODO(V): sort these sanely
     root-title=unfathomable software
     root-desc=sufficiently advanced technology
-    # TODO(V): root-readme? what should go in here, contribution info? info about the server? info about the branch conventions?
-    enable-index-owner=0
 
     logo=/un.svg
     favicon=/unicon.svg
-    # TODO(V): footer=https://src.unfathomable.blue/nixos-config/commit/?id={commit}
+    # TODO(V): footer=https://src.unfathomable.blue/commit/?id={commit}
     mimetype-file=${pkgs.mime-types}/etc/mime.types
-    # TODO(V): repository-sort=age?
-    # TODO(V): robots=none? (same as noindex, nofollow)
     readme=:README.adoc
-    clone-prefix=https://src.unfathomable.blue
-    agefile=info/last-modified
     about-filter=${cgit-about-filter}
     # TODO(edef): commit-filter, for bug tracker links
     source-filter=${cgit-package}/lib/cgit/filters/syntax-highlighting.py
     # TODO(edef): add snapshots once we start releasing things
     # TODO(V): branch-sort=age?
-    enable-git-config=1
 
-    # Has to go last.
-    # Options set after this won't be applied due to how they're evaluated.
-    scan-path=/var/lib/git
-    # TODO(V): section-from-path?
-    # TODO(V): repository-specific logos
-    # TODO(V): other repository-specific options
+    repo.url=basin
+    repo.path=/var/lib/git/basin
+    repo.clone-url=https://src.unfathomable.blue/
+
+    # TODO(V): add per-subtree project description/logo/etc support to cgit
   '';
 in {
   services.cgiserver.instances.cgit = {
@@ -81,11 +76,17 @@ in {
     src.unfathomable.blue {
       import common
 
-      root * ${cgit-webroot}
-      @exists file
-
       route {
+        root * ${cgit-webroot}
+        @exists file
         file_server @exists
+
+        # CGit doesn't currently have a straightforward way of serving
+        # a repository at the root, so we cheat by internally rewriting
+        # all URLs to be relative to a named repository, and patching
+        # CGit to elide this prefix from generated links.
+        rewrite * /basin{path}
+
         reverse_proxy unix//run/cgit/cgit.sock
       }
     }
@@ -97,13 +98,5 @@ in {
     (pkgs.writeShellScript "update-server-info" ''
       git update-server-info
     '')
-
-    # Update the last-modified timestamp that cgit uses to measure freshness
-    (pkgs.writeShellScript "update-agefile" ''
-      git for-each-ref \
-        --sort=-creatordate --count=1 \
-        --format='%(creatordate:iso)' \
-        >info/last-modified
-    '')
   ];
 }