diff mbox series

[bug#37412,1/2] gnu: Add guix-data-service.

Message ID 20190922120337.3533-1-mail@cbaines.net
State Accepted
Headers show
Series [bug#37412,1/2] gnu: Add guix-data-service. | expand

Commit Message

Christopher Baines Sept. 22, 2019, 12:03 p.m. UTC
* gnu/packages/web.scm (guix-data-service): New variable.
---
 gnu/packages/web.scm | 102 +++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 102 insertions(+)

Comments

Ludovic Courtès Sept. 22, 2019, 9:11 p.m. UTC | #1
Christopher Baines <mail@cbaines.net> skribis:

> * gnu/packages/web.scm (guix-data-service): New variable.

[...]

> +      (native-inputs
> +       `(("autoconf" ,autoconf)
> +         ("automake" ,automake)
> +         ("emacs-with-modules" ,(directory-union
> +                                 "emacs-union"
> +                                 (list emacs-no-x
> +                                       emacs-htmlize)))

Should it be ‘emacs-minimal’?

> +      (native-search-paths
> +       ;; XXX guile-git requires this to be set, maybe there's a better way
> +       (list (search-path-specification
> +              (variable "GIT_SSL_CAINFO")
> +              (file-type 'regular)
> +              (separator #f)
> +              (files '("etc/ssl/certs/ca-certificates.crt")))))

Like I wrote, I’d rather remove the search path and add the environment
variable…

> +      (start #~(make-forkexec-constructor
> +                (list #$(file-append package
> +                                     "/bin/guix-data-service")
> +                      "--pid-file=/var/run/guix-data-service/pid"
> +                      #$(string-append "--port=" (number->string port))
> +                      #$(string-append "--host=" host)
> +                      ;; Perform any database migrations when the
> +                      ;; service is started
> +                      "--update-database")
> +
> +                #:user #$user
> +                #:group #$group
> +                #:pid-file "/var/run/guix-data-service/pid"
> +                ;; Allow time for migrations to run
> +                #:pid-file-timeout 60
> +                #:environment-variables
> +                `(,(string-append
> +                    "GUIX_LOCPATH=" #$glibc-utf8-locales "/lib/locale")
> +                  "LC_ALL=en_US.utf8")
> +                #:log-file "/var/log/guix-data-service/web.log"))

… here.           ↑

But anyway, these are details so I think you can go ahead and push as
you see fit.

Thanks!

Ludo’.
Christopher Baines Sept. 24, 2019, 7:34 p.m. UTC | #2
Ludovic Courtès <ludo@gnu.org> writes:

> Christopher Baines <mail@cbaines.net> skribis:
>
>> * gnu/packages/web.scm (guix-data-service): New variable.
>
> [...]
>
>> +      (native-inputs
>> +       `(("autoconf" ,autoconf)
>> +         ("automake" ,automake)
>> +         ("emacs-with-modules" ,(directory-union
>> +                                 "emacs-union"
>> +                                 (list emacs-no-x
>> +                                       emacs-htmlize)))
>
> Should it be ‘emacs-minimal’?

It probably could be, but at the moment this doesn't work with the Emacs
Lisp code that's run at package build time to convert the README to HTML
[1].

1: https://git.savannah.gnu.org/cgit/guix/data-service.git/tree/Makefile.am#n35

Do you know if there's a way to remove the need for the autoloading
behaviour from the guix-emacs.el file? The error I get when using
emacs-minimal suggests htmlize isn't being found.

>> +      (native-search-paths
>> +       ;; XXX guile-git requires this to be set, maybe there's a better way
>> +       (list (search-path-specification
>> +              (variable "GIT_SSL_CAINFO")
>> +              (file-type 'regular)
>> +              (separator #f)
>> +              (files '("etc/ssl/certs/ca-certificates.crt")))))
>
> Like I wrote, I’d rather remove the search path and add the environment
> variable…

Yeah, I'm actually unsure if this is doing anything. I'll remove it.

>> +      (start #~(make-forkexec-constructor
>> +                (list #$(file-append package
>> +                                     "/bin/guix-data-service")
>> +                      "--pid-file=/var/run/guix-data-service/pid"
>> +                      #$(string-append "--port=" (number->string port))
>> +                      #$(string-append "--host=" host)
>> +                      ;; Perform any database migrations when the
>> +                      ;; service is started
>> +                      "--update-database")
>> +
>> +                #:user #$user
>> +                #:group #$group
>> +                #:pid-file "/var/run/guix-data-service/pid"
>> +                ;; Allow time for migrations to run
>> +                #:pid-file-timeout 60
>> +                #:environment-variables
>> +                `(,(string-append
>> +                    "GUIX_LOCPATH=" #$glibc-utf8-locales "/lib/locale")
>> +                  "LC_ALL=en_US.utf8")
>> +                #:log-file "/var/log/guix-data-service/web.log"))
>
> … here.           ↑

So, this shepherd service which serves requests doesn't do any Git
access, and the process jobs shepherd service defined below actually
already sets it:

  "GIT_SSL_CAINFO=/etc/ssl/certs/ca-certificates.crt"

So yeah, I think I can just remove the native-search-paths bit from the
package definition.

> But anyway, these are details so I think you can go ahead and push as
> you see fit.

Great, thanks for taking a look Ludo!

Chris
diff mbox series

Patch

diff --git a/gnu/packages/web.scm b/gnu/packages/web.scm
index 39475bd6a8..065979f959 100644
--- a/gnu/packages/web.scm
+++ b/gnu/packages/web.scm
@@ -56,6 +56,7 @@ 
   #:use-module ((guix licenses) #:prefix license:)
   #:use-module (guix packages)
   #:use-module (guix download)
+  #:use-module (guix gexp)
   #:use-module (guix git-download)
   #:use-module (guix cvs-download)
   #:use-module (guix hg-download)
@@ -77,6 +78,8 @@ 
   #:use-module (gnu packages check)
   #:use-module (gnu packages documentation)
   #:use-module (gnu packages docbook)
+  #:use-module (gnu packages emacs)
+  #:use-module (gnu packages emacs-xyz)
   #:use-module (gnu packages autotools)
   #:use-module (gnu packages compression)
   #:use-module (gnu packages curl)
@@ -3973,6 +3976,105 @@  CDF, Atom 0.3, and Atom 1.0 feeds.")
 (define-public python2-feedparser
   (package-with-python2 python-feedparser))
 
+(define-public guix-data-service
+  (let ((commit "970bcb31cf994b0e3b67e7f912734e5b53355d8d")
+        (revision "1"))
+    (package
+      (name "guix-data-service")
+      (version (string-append "0.0.1-" revision "." (string-take commit 7)))
+      (source (origin
+                (method git-fetch)
+                (uri (git-reference
+                      (url "https://git.savannah.gnu.org/git/guix/data-service.git")
+                      (commit commit)))
+                (file-name (git-file-name name version))
+                (sha256
+                 (base32
+                  "0wiw1m4g30sx155ldjrg4060ydqwgxv93day89pf6w515n5fv08j"))))
+      (build-system gnu-build-system)
+      (arguments
+       '(#:tests? #f                    ; TODO Tests require PostgreSQL
+         #:modules ((guix build utils)
+                    (guix build gnu-build-system)
+                    (ice-9 rdelim)
+                    (ice-9 popen))
+         #:phases
+         (modify-phases %standard-phases
+           (add-after 'set-paths 'set-GUIX_ENVIRONMENT
+             (lambda* (#:key inputs #:allow-other-keys)
+               ;; This means guix.el finds the Emacs modules
+               (setenv "GUIX_ENVIRONMENT"
+                       (assoc-ref inputs "emacs-with-modules"))
+               #t))
+           (add-before 'build 'set-GUILE_AUTO_COMPILE
+             (lambda _
+               ;; To avoid errors relating to guild
+               (setenv "GUILE_AUTO_COMPILE" "0")
+               #t))
+           (add-after 'install 'wrap-executable
+             (lambda* (#:key inputs outputs #:allow-other-keys)
+               (let* ((out (assoc-ref outputs "out"))
+                      (bin (string-append out "/bin"))
+                      (guile (assoc-ref inputs "guile"))
+                      (guile-effective-version
+                       (read-line
+                        (open-pipe* OPEN_READ
+                                    (string-append guile "/bin/guile")
+                                    "-c" "(display (effective-version))")))
+                      (scm (string-append out "/share/guile/site/"
+                                          guile-effective-version))
+                      (go  (string-append out "/lib/guile/"
+                                          guile-effective-version
+                                          "/site-ccache")))
+                 (for-each
+                  (lambda (file)
+                    (wrap-program (string-append bin "/" file)
+                      `("PATH" ":" prefix
+                        (,bin))
+                      `("GUILE_LOAD_PATH" ":" prefix
+                        (,scm ,(getenv "GUILE_LOAD_PATH")))
+                      `("GUILE_LOAD_COMPILED_PATH" ":" prefix
+                        (,go ,(getenv "GUILE_LOAD_COMPILED_PATH")))))
+                  '("guix-data-service"
+                    "guix-data-service-process-branch-updated-email"
+                    "guix-data-service-process-job"
+                    "guix-data-service-process-jobs"
+                    "guix-data-service-query-build-servers"))
+                 #t)))
+           (delete 'strip))))           ; As the .go files aren't compatible
+      (inputs
+       `(("guile" ,guile-2.2)
+         ("guix" ,guix)
+         ("guile-fibers" ,guile-fibers)
+         ("guile-json" ,guile-json-3)
+         ("guile-email" ,guile-email)
+         ("guile-squee" ,guile-squee)
+         ("postgresql" ,postgresql)
+         ("sqitch" ,sqitch)))
+      (native-inputs
+       `(("autoconf" ,autoconf)
+         ("automake" ,automake)
+         ("emacs-with-modules" ,(directory-union
+                                 "emacs-union"
+                                 (list emacs-no-x
+                                       emacs-htmlize)))
+         ("pkg-config" ,pkg-config)))
+      (native-search-paths
+       ;; XXX guile-git requires this to be set, maybe there's a better way
+       (list (search-path-specification
+              (variable "GIT_SSL_CAINFO")
+              (file-type 'regular)
+              (separator #f)
+              (files '("etc/ssl/certs/ca-certificates.crt")))))
+      (synopsis "Store and provide data about GNU Guix")
+      (description
+       "The Guix Data Service stores data about GNU Guix, and provides this
+through a web interface.  It supports listening to the guix-commits mailing
+list to find out about new revisions, then loads the data from these in to a
+PostgreSQL database.")
+      (home-page "http://data.guix.gnu.org/")
+      (license license:agpl3+))))
+
 (define-public gumbo-parser
   (package
     (name "gumbo-parser")