about summary refs log tree commit diff
path: root/guix
diff options
context:
space:
mode:
authorArun Isaac2026-08-04 01:18:12 +0100
committerArun Isaac2026-08-04 13:24:54 +0100
commit685db9d6fd90b76a8314a21328217039932b6070 (patch)
treef26b5795631487c122dc84b41ae6654158d08827 /guix
parent321bfd3891c23fceba2660ff68a17febb6083465 (diff)
downloadguix-forge-685db9d6fd90b76a8314a21328217039932b6070.tar.gz
guix-forge-685db9d6fd90b76a8314a21328217039932b6070.tar.lz
guix-forge-685db9d6fd90b76a8314a21328217039932b6070.zip
cgit: Switch from Pygments to Chroma.
Chroma is a lot faster than Pygments, probably in part due to it not
incurring the Python interpreter startup overhead. Thus, it will
perform better as a source filter, and will hold up well to the
onslaught of the AI crawlers.
Diffstat (limited to 'guix')
-rw-r--r--guix/forge/cgit.scm21
1 files changed, 18 insertions, 3 deletions
diff --git a/guix/forge/cgit.scm b/guix/forge/cgit.scm
index 94a62ee..529d4a6 100644
--- a/guix/forge/cgit.scm
+++ b/guix/forge/cgit.scm
@@ -25,6 +25,7 @@
   #:use-module (forge socket)
   #:use-module ((gnu packages emacs) #:select (emacs-minimal))
   #:use-module ((gnu packages mail) #:select (mailcap))
+  #:use-module ((gnu packages golang-apps) #:select (go-chroma))
   #:use-module ((gnu packages version-control)
                 #:select (cgit-pink git-minimal))
   #:use-module (gnu services)
@@ -70,6 +71,21 @@
                 "README.txt"
                 "README")))
 
+(define %cgit-chroma-syntax-highlight-gexp
+  (with-imported-modules '((guix build utils))
+    #~(begin
+        (use-modules (guix build utils)
+                     (ice-9 match))
+
+        (match (command-line)
+          ((_ file)
+           (invoke #$(file-append go-chroma "/bin/chroma")
+                   "--style" "pastie"
+                   "--html"
+                   "--html-only"
+                   "--html-inline-styles"
+                   "--filename" file))))))
+
 (define-record-type* <cgit-configuration>
   cgit-configuration make-cgit-configuration
   cgit-configuration?
@@ -99,9 +115,8 @@
   (email-filter cgit-configuration-email-filter
                 (default #f))
   (source-filter cgit-configuration-source-filter
-                 (default (file-append (cgit-configuration-cgit
-                                        this-cgit-configuration)
-                                       "/lib/cgit/filters/syntax-highlighting.py"))
+                 (default (program-file "cgit-chroma-syntax-highlight"
+                                        %cgit-chroma-syntax-highlight-gexp))
                  (thunked))
   (mimetype-file cgit-configuration-mimetype-file
                  (default (file-append mailcap "/etc/mime.types")))