guix-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[bug#28283] Status: [PATCH 1/1] gnu: services: version-control: Add cgit


From: Ludovic Courtès
Subject: [bug#28283] Status: [PATCH 1/1] gnu: services: version-control: Add cgit.
Date: Sun, 01 Oct 2017 23:55:16 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux)

Hi Oleg,

Oleg Pykhalov <address@hidden> 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 <address@hidden>
> 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):

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
 
address@hidden Cgit service
address@hidden Cgit Service
 
address@hidden Cgit service
address@hidden 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 <address@hidden>
 ;;; Copyright © 2016 Sou Bunnbu <address@hidden>
+;;; Copyright © 2017 Oleg Pykhalov <address@hidden>
 ;;;
 ;;; 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
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’.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]