diff mbox series

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

Message ID 20190915182127.10525-1-mail@cbaines.net
State Accepted
Headers show
Series Add package and service for the Guix Data Service. | expand

Commit Message

Christopher Baines Sept. 15, 2019, 6:21 p.m. UTC
* gnu/packages/web.scm (guix-data-service): New variable.
---
 gnu/packages/web.scm | 83 ++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 83 insertions(+)

Comments

Alex ter Weele Sept. 15, 2019, 8:45 p.m. UTC | #1
Christopher Baines <mail@cbaines.net> writes:

> * gnu/packages/web.scm (guix-data-service): New variable.
> ---
>  gnu/packages/web.scm | 83 ++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 83 insertions(+)
>
> diff --git a/gnu/packages/web.scm b/gnu/packages/web.scm
> index 39475bd6a8..30adc75aa1 100644
> --- a/gnu/packages/web.scm
> +++ b/gnu/packages/web.scm
> @@ -3973,6 +3973,89 @@ 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 "6a9f11fb94fbfd969396dd4d9f768a0c9ec67734")
> +        (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
> +                  "08kfi74dp8h1i03gfmjqfv07ff7m93psnh6xmrgwzr0ja5cdqjri"))))
> +      (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 '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))))))
> +      (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)
> +         ("pkg-config" ,pkg-config)))
> +      (native-search-paths
> +       ;; guile-git requires this to be set
> +       (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 "https://data.guix.gnu.org/")

I found that only http://data.guix.gnu.org/ works.

> 
> + (license license:agpl3+)))) + (define-public gumbo-parser (package
> (name "gumbo-parser")
Christopher Baines Sept. 15, 2019, 9:29 p.m. UTC | #2
Alex ter Weele <alex.ter.weele@gmail.com> writes:

>> +      (home-page "https://data.guix.gnu.org/")
>
> I found that only http://data.guix.gnu.org/ works.

Good spot. When I wrote this, I was planning on setting up HTTPS for
data.guix.gnu.org, but when I came to do it, I didn't quite know how to
configure it. It's still on my list of things to do, but I've now
changed the patch to use http.
Ludovic Courtès Sept. 16, 2019, 7:48 a.m. UTC | #3
Good morning, Chris!

Christopher Baines <mail@cbaines.net> skribis:

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

Woohoo!  \o/

> +      (inputs
> +       `(("guile" ,guile-2.2)

Guile should be ‘native-inputs’ because we use it for its compiler
(which can act as a “cross-compiler” with ‘--target’).

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

It’s a bit of a workaround for
<https://issues.guix.gnu.org/issue/22138>, isn’t it?  :-)

What about either removing it, or adding an “XXX” to the comment?

Otherwise LGTM!

Ludo’.
Ludovic Courtès Sept. 16, 2019, 7:55 a.m. UTC | #4
Christopher Baines <mail@cbaines.net> skribis:

> +      (home-page "https://data.guix.gnu.org/")

It would be nice to add a reference to data.guix.gnu.org at
<https://guix.gnu.org/contribute/> or in the manual.  WDYT?

Ludo’.
Christopher Baines Sept. 22, 2019, 10:10 a.m. UTC | #5
Ludovic Courtès <ludo@gnu.org> writes:

> Christopher Baines <mail@cbaines.net> skribis:
>
>> +      (home-page "https://data.guix.gnu.org/")
>
> It would be nice to add a reference to data.guix.gnu.org at
> <https://guix.gnu.org/contribute/> or in the manual.  WDYT?

Yeah, maybe there could be a "Services" section, and that could mention
Cuirass, Mumi, and the Guix Data Service.
Christopher Baines Sept. 22, 2019, 10:18 a.m. UTC | #6
Ludovic Courtès <ludo@gnu.org> writes:

> Good morning, Chris!
>
> Christopher Baines <mail@cbaines.net> skribis:
>
>> * gnu/packages/web.scm (guix-data-service): New variable.
>
> Woohoo!  \o/
>
>> +      (inputs
>> +       `(("guile" ,guile-2.2)
>
> Guile should be ‘native-inputs’ because we use it for its compiler
> (which can act as a “cross-compiler” with ‘--target’).

This makes sense, but the scripts will still refer to the guile used to
build the package, so building for a different architecture won't work
right? Does the package somehow need to take as input two Guiles, one
for build time, and one for runtime?

>> +      (native-search-paths
>> +       ;; guile-git requires this to be set
>> +       (list (search-path-specification
>> +              (variable "GIT_SSL_CAINFO")
>> +              (file-type 'regular)
>> +              (separator #f)
>> +              (files '("etc/ssl/certs/ca-certificates.crt")))))
>
> It’s a bit of a workaround for
> <https://issues.guix.gnu.org/issue/22138>, isn’t it?  :-)
>
> What about either removing it, or adding an “XXX” to the comment?

I can't quite remember, I think I added that a long while ago when
trying to get the Guix service working. I'm not sure it's a great
approach. I'll add XXX to the comment though.
Ludovic Courtès Sept. 22, 2019, 9:04 p.m. UTC | #7
Hi Chris,

Christopher Baines <mail@cbaines.net> skribis:

> Ludovic Courtès <ludo@gnu.org> writes:
>
>> Good morning, Chris!
>>
>> Christopher Baines <mail@cbaines.net> skribis:
>>
>>> * gnu/packages/web.scm (guix-data-service): New variable.
>>
>> Woohoo!  \o/
>>
>>> +      (inputs
>>> +       `(("guile" ,guile-2.2)
>>
>> Guile should be ‘native-inputs’ because we use it for its compiler
>> (which can act as a “cross-compiler” with ‘--target’).
>
> This makes sense, but the scripts will still refer to the guile used to
> build the package, so building for a different architecture won't work
> right? Does the package somehow need to take as input two Guiles, one
> for build time, and one for runtime?

Yes, we probably need to have Guile both as input and native input.
Well don’t lose your hair on it anyway.

>>> +      (native-search-paths
>>> +       ;; guile-git requires this to be set
>>> +       (list (search-path-specification
>>> +              (variable "GIT_SSL_CAINFO")
>>> +              (file-type 'regular)
>>> +              (separator #f)
>>> +              (files '("etc/ssl/certs/ca-certificates.crt")))))
>>
>> It’s a bit of a workaround for
>> <https://issues.guix.gnu.org/issue/22138>, isn’t it?  :-)
>>
>> What about either removing it, or adding an “XXX” to the comment?
>
> I can't quite remember, I think I added that a long while ago when
> trying to get the Guix service working. I'm not sure it's a great
> approach. I'll add XXX to the comment though.

What about removing it altogether and instead setting GIT_SSL_CAINFO in
the service itself?

Thanks,
Ludo’.
Christopher Baines Sept. 25, 2019, 7:46 a.m. UTC | #8
Ludovic Courtès <ludo@gnu.org> writes:

> Hi Chris,
>
> Christopher Baines <mail@cbaines.net> skribis:
>
>> Ludovic Courtès <ludo@gnu.org> writes:
>>
>>> Good morning, Chris!
>>>
>>> Christopher Baines <mail@cbaines.net> skribis:
>>>
>>>> * gnu/packages/web.scm (guix-data-service): New variable.
>>>
>>> Woohoo!  \o/
>>>
>>>> +      (inputs
>>>> +       `(("guile" ,guile-2.2)
>>>
>>> Guile should be ‘native-inputs’ because we use it for its compiler
>>> (which can act as a “cross-compiler” with ‘--target’).
>>
>> This makes sense, but the scripts will still refer to the guile used to
>> build the package, so building for a different architecture won't work
>> right? Does the package somehow need to take as input two Guiles, one
>> for build time, and one for runtime?
>
> Yes, we probably need to have Guile both as input and native input.
> Well don’t lose your hair on it anyway.

I've just gone with making it a native input for now.

>>>> +      (native-search-paths
>>>> +       ;; guile-git requires this to be set
>>>> +       (list (search-path-specification
>>>> +              (variable "GIT_SSL_CAINFO")
>>>> +              (file-type 'regular)
>>>> +              (separator #f)
>>>> +              (files '("etc/ssl/certs/ca-certificates.crt")))))
>>>
>>> It’s a bit of a workaround for
>>> <https://issues.guix.gnu.org/issue/22138>, isn’t it?  :-)
>>>
>>> What about either removing it, or adding an “XXX” to the comment?
>>
>> I can't quite remember, I think I added that a long while ago when
>> trying to get the Guix service working. I'm not sure it's a great
>> approach. I'll add XXX to the comment though.
>
> What about removing it altogether and instead setting GIT_SSL_CAINFO in
> the service itself?

Turns out I was already setting GIT_SSL_CAINFO in the service, so I've
removed the native-search-paths from the package definition.

I've now pushed both patches, thanks for taking a look!

Chris
diff mbox series

Patch

diff --git a/gnu/packages/web.scm b/gnu/packages/web.scm
index 39475bd6a8..30adc75aa1 100644
--- a/gnu/packages/web.scm
+++ b/gnu/packages/web.scm
@@ -3973,6 +3973,89 @@  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 "6a9f11fb94fbfd969396dd4d9f768a0c9ec67734")
+        (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
+                  "08kfi74dp8h1i03gfmjqfv07ff7m93psnh6xmrgwzr0ja5cdqjri"))))
+      (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 '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))))))
+      (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)
+         ("pkg-config" ,pkg-config)))
+      (native-search-paths
+       ;; guile-git requires this to be set
+       (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 "https://data.guix.gnu.org/")
+      (license license:agpl3+))))
+
 (define-public gumbo-parser
   (package
     (name "gumbo-parser")