GNU bug report logs - #28283
[PATCH 0/1] gnu: services: version-control: Add cgit.

Previous Next

Package: guix-patches;

Reported by: Oleg Pykhalov <go.wigust <at> gmail.com>

Date: Tue, 29 Aug 2017 21:17:01 UTC

Severity: normal

Tags: patch

Done: ludo <at> gnu.org (Ludovic Courtès)

Bug is archived. No further changes may be made.

Full log


Message #35 received at 28283 <at> debbugs.gnu.org (full text, mbox):

From: ludo <at> gnu.org (Ludovic Courtès)
To: Oleg Pykhalov <go.wigust <at> gmail.com>
Cc: 28283 <at> debbugs.gnu.org
Subject: Re: [bug#28283] Status: [PATCH 1/1] gnu: services: version-control:
 Add cgit.
Date: Sun, 01 Oct 2017 23:55:16 +0200
[Message part 1 (text/plain, inline)]
Hi Oleg,

Oleg Pykhalov <go.wigust <at> gmail.com> skribis:

> ‘try-files’ are in ‘<nginx-server-configuration>’ in origin/master now,
> https://git.savannah.gnu.org/cgit/guix.git/commit/?id=4d14808af4c01b4fb0a4564584aa68f0e53c4ef4

Awesome.

>> Please add a sentence above or below the example like “This example
>> shows …”.
>
> Sorry, I don't understand what do you mean.  There is a sentence above
> example that answers a question “What does example do?” and I guess
> “What does example show?”.

Oops you’re right, sorry for overlooking this.

> From 64b328c90fbaedca4b081fb33af6e3dbae27eeb6 Mon Sep 17 00:00:00 2001
> From: Oleg Pykhalov <go.wigust <at> gmail.com>
> Date: Thu, 28 Sep 2017 20:02:35 +0300
> Subject: [PATCH] gnu: services: version-control: Add cgit.
>
> * gnu/services/version-control.scm
> (<cgit-configuration-file>, <cgit-configuration>): New record types.
> (cgit-configuration-robots-string, cgit-activation,
> cgit-configuration-nginx-config): New procedures.
> (%cgit-configuration-nginx, cgit-service-type): New variables.
> * doc/guix.texi (Version Control): Document the cgit service.

[...]

> +(define-gexp-compiler (cgit-configuration-file-compiler
> +                       (file <cgit-configuration-file>) system target)
> +  (match file
> +    (($ <cgit-configuration-file> css logo
> +                                  robots virtual-root repository-directory)
> +     (text-file
> +      "cgitrc"
> +      (string-concatenate
> +       (filter-map
> +        (match-lambda
> +          ((key . #f) #f)
> +          ((key . value) (string-append key "=" value "\n")))
> +        `(("css" . ,css)
> +          ("logo" . ,logo)
> +          ("robots" . ,(cgit-configuration-robots-string robots))
> +          ("virtual-root" . ,virtual-root)
> +          ("repository-directory" . ,repository-directory))))))))

I changed this part like this so that things work as expected if we pass
items that live in the store (along with other changes):

[Message part 2 (text/x-patch, inline)]
diff --git a/doc/guix.texi b/doc/guix.texi
index 4bdbe4b70..d5abf900a 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -17000,8 +17000,10 @@ Extra options will be passed to @code{git daemon}, please run
 @end table
 @end deftp
 
-@subsubheading Cgit service
+@subsubheading Cgit Service
 
+@cindex Cgit service
+@cindex Git, web interface
 @uref{https://git.zx2c4.com/cgit/, Cgit} is a web frontend for Git
 repositories written in C.
 
diff --git a/gnu/services/version-control.scm b/gnu/services/version-control.scm
index 50b09c0ce..208351447 100644
--- a/gnu/services/version-control.scm
+++ b/gnu/services/version-control.scm
@@ -1,6 +1,7 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2016 ng0 <ng0 <at> we.make.ritual.n0.is>
 ;;; Copyright © 2016 Sou Bunnbu <iyzsong <at> member.fsf.org>
+;;; Copyright © 2017 Oleg Pykhalov <go.wigust <at> gmail.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -189,18 +190,23 @@ access to exported repositories under @file{/srv/git}."
   (match file
     (($ <cgit-configuration-file> css logo
                                   robots virtual-root repository-directory)
-     (text-file
-      "cgitrc"
-      (string-concatenate
-       (filter-map
-        (match-lambda
-          ((key . #f) #f)
-          ((key . value) (string-append key "=" value "\n")))
-        `(("css" . ,css)
-          ("logo" . ,logo)
-          ("robots" . ,(cgit-configuration-robots-string robots))
-          ("virtual-root" . ,virtual-root)
-          ("repository-directory" . ,repository-directory))))))))
+     (apply text-file* "cgitrc"
+            (letrec-syntax ((option (syntax-rules ()
+                                      ((_ key value)
+                                       (if value
+                                           `(,key "=" ,value)
+                                           '()))))
+                            (key/value (syntax-rules ()
+                                         ((_ (key value) rest ...)
+                                          (append (option key value)
+                                                  (key/value rest ...)))
+                                         ((_)
+                                          '()))))
+              (key/value ("css" css)
+                         ("logo" logo)
+                         ("robots" (cgit-configuration-robots-string robots))
+                         ("virtual-root" virtual-root)
+                         ("repository-directory" repository-directory)))))))
 
 (define %cgit-configuration-nginx
   (list
[Message part 3 (text/plain, inline)]
I looked at the test failures, and I wonder if everything’s working as
intended.  What I did for debugging was:

--8<---------------cut here---------------start------------->8---
$ guix gc -R  /gnu/store/i71plcn5y8b29nc59s5d7m2cx810ki6n-cgit-test.drv |grep run-vm
/gnu/store/v9s4ai0dvgvmga6lyj4z2733lavr3acl-run-vm.sh-builder
/gnu/store/6a2l7mcshdzc38zj8nkinjlzqmgjnx3b-run-vm.sh.drv
$ guix build /gnu/store/6a2l7mcshdzc38zj8nkinjlzqmgjnx3b-run-vm.sh.drv
/gnu/store/igjg0i4d3sj77jpgppn09r66jql6nliw-run-vm.sh
$ /gnu/store/igjg0i4d3sj77jpgppn09r66jql6nliw-run-vm.sh -serial stdio
…
--8<---------------cut here---------------end--------------->8---

Then I experimented with w3m inside the VM.

Apparently some URLs are being rewritten, with
/cgit.cgi/cgit.cgi/cgit.cgi/… and so on, which looks weird.

Could you investigate more in a VM (you can simply use ‘guix system vm’
with a config similar to that of the test) to see what’s going on?
Looks like we’re almost there, but I’d feel more confident if we could
get a test running.  :-)

Thank you!

Ludo’.

This bug report was last modified 7 years and 293 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.