[PATCH] services: Add whoogle-service-type.

  • Done
  • quality assurance status badge
Details
4 participants
  • conses
  • Ludovic Courtès
  • Miguel Ángel Moreno
  • Bruno Victal
Owner
unassigned
Submitted by
conses
Severity
normal
C
C
conses wrote on 10 Mar 2023 21:11
(address . guix-patches@gnu.org)
86zg8k8iy8.fsf@conses.eu
---
gnu/services/web.scm | 46 ++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 46 insertions(+)

Toggle diff (86 lines)
diff --git a/gnu/services/web.scm b/gnu/services/web.scm
index d56e893527..66cc640a6d 100644
--- a/gnu/services/web.scm
+++ b/gnu/services/web.scm
@@ -35,6 +35,7 @@ (define-module (gnu services web)
#:use-module (gnu services)
#:use-module (gnu services shepherd)
#:use-module (gnu services admin)
+ #:use-module (gnu services configuration)
#:use-module (gnu services getmail)
#:use-module (gnu services mail)
#:use-module (gnu system pam)
@@ -46,6 +47,7 @@ (define-module (gnu services web)
#:use-module (gnu packages patchutils)
#:use-module (gnu packages php)
#:use-module (gnu packages python)
+ #:use-module (gnu packages python-web)
#:use-module (gnu packages gnupg)
#:use-module (gnu packages guile)
#:use-module (gnu packages logging)
@@ -235,6 +237,9 @@ (define-module (gnu services web)
varnish-service-type
+ whoogle-service-type
+ whoogle-configuration
+
patchwork-database-configuration
patchwork-database-configuration?
patchwork-database-configuration-engine
@@ -1575,6 +1580,47 @@ (define varnish-service-type
(default-value
(varnish-configuration))))
+
+;;;
+;;; Whoogle
+;;;
+
+(define-configuration/no-serialization whoogle-configuration
+ (whoogle
+ (package whoogle-search)
+ "The @code{whoogle-search} package to use."))
+
+(define (whoogle-shepherd-service config)
+ (list
+ (shepherd-service
+ (provision '(whoogle-search))
+ (start #~(make-forkexec-constructor
+ (list (string-append #$(whoogle-configuration-whoogle config)
+ "/bin/whoogle-search"))
+ #:environment-variables
+ (append (list "CONFIG_VOLUME=/var/cache/whoogle-search")
+ (default-environment-variables))))
+ (stop #~(make-kill-destructor))
+ (documentation "Run a @code{whoogle-search} instance."))))
+
+(define (whoogle-profile-service config)
+ (list
+ (whoogle-configuration-whoogle config)))
+
+(define whoogle-service-type
+ (service-type
+ (name 'whoogle-search)
+ (extensions
+ (list
+ (service-extension
+ shepherd-root-service-type
+ whoogle-shepherd-service)
+ (service-extension
+ profile-service-type
+ whoogle-profile-service)))
+ (default-value (whoogle-configuration))
+ (description "Run the @code{whoogle-search} engine.")))
+
;;;
;;; Patchwork
--
2.39.1



--
Best regards,
conses
B
B
Bruno Victal wrote on 31 Mar 2023 13:30
(name . conses)(address . contact@conses.eu)
4c4ede32-0615-8134-0d47-ae18ed75531b@makinata.eu
Hi,

On 2023-03-10 20:11, conses wrote:
Toggle quote (5 lines)
>
> + whoogle-service-type
> + whoogle-configuration
> +

[...]

Toggle quote (9 lines)
> patchwork-database-configuration
> patchwork-database-configuration?
> patchwork-database-configuration-engine
> @@ -1575,6 +1580,47 @@ (define varnish-service-type
> (default-value
> (varnish-configuration))))
>
> +

Missing page-break character here?
If you're using Emacs you can insert one with C-q C-l.

Toggle quote (9 lines)
> +;;;
> +;;; Whoogle
> +;;;
> +
> +(define-configuration/no-serialization whoogle-configuration
> + (whoogle
> + (package whoogle-search)
> + "The @code{whoogle-search} package to use."))

I prefer this field to be named 'package' instead, to make it less prone
to confusion. The accessor, whoogle-configuration-package, should be exported
as well.

Toggle quote (8 lines)
> +(define (whoogle-shepherd-service config)
> + (list
> + (shepherd-service
> + (provision '(whoogle-search))
> + (start #~(make-forkexec-constructor
> + (list (string-append #$(whoogle-configuration-whoogle config)
> + "/bin/whoogle-search"))

In general, you may prefer to use match-record instead of using accessors
as it results in much less code to type.

Toggle quote (4 lines)
> + #:environment-variables
> + (append (list "CONFIG_VOLUME=/var/cache/whoogle-search")
> + (default-environment-variables))))

Is (default-environment-variables) necessary?

Toggle quote (7 lines)
> + (stop #~(make-kill-destructor))
> + (documentation "Run a @code{whoogle-search} instance."))))
> +
> +(define (whoogle-profile-service config)
> + (list
> + (whoogle-configuration-whoogle config)))

[...]

Toggle quote (13 lines)
> +
> +(define whoogle-service-type
> + (service-type
> + (name 'whoogle-search)
> + (extensions
> + (list
> + (service-extension
> + shepherd-root-service-type
> + whoogle-shepherd-service)
> + (service-extension
> + profile-service-type
> + whoogle-profile-service)))

You can use match-record here or use the accessor here instead.
(e.g., (compose list whoogle-configuration-package))


Could you add a system test for this service as well?
It makes things easier to check and maintain.


Cheers,
Bruno
L
L
Ludovic Courtès wrote on 9 Jun 2023 23:03
Re: bug#62102: [PATCH] services: Add whoogle-service-type.
(name . conses)(address . contact@conses.eu)
87ttvgtkjs.fsf_-_@gnu.org
Hi conses,

Did you have a chance to look into Bruno’s suggestions below?

Please let us know what you think.

Thanks in advance,
Ludo’.

Bruno Victal <mirai@makinata.eu> skribis:

Toggle quote (84 lines)
> Hi,
>
> On 2023-03-10 20:11, conses wrote:
>>
>> + whoogle-service-type
>> + whoogle-configuration
>> +
>
> [...]
>
>> patchwork-database-configuration
>> patchwork-database-configuration?
>> patchwork-database-configuration-engine
>> @@ -1575,6 +1580,47 @@ (define varnish-service-type
>> (default-value
>> (varnish-configuration))))
>>
>> +
>
> Missing page-break character here?
> If you're using Emacs you can insert one with C-q C-l.
>
>> +;;;
>> +;;; Whoogle
>> +;;;
>> +
>> +(define-configuration/no-serialization whoogle-configuration
>> + (whoogle
>> + (package whoogle-search)
>> + "The @code{whoogle-search} package to use."))
>
> I prefer this field to be named 'package' instead, to make it less prone
> to confusion. The accessor, whoogle-configuration-package, should be exported
> as well.
>
>> +(define (whoogle-shepherd-service config)
>> + (list
>> + (shepherd-service
>> + (provision '(whoogle-search))
>> + (start #~(make-forkexec-constructor
>> + (list (string-append #$(whoogle-configuration-whoogle config)
>> + "/bin/whoogle-search"))
>
> In general, you may prefer to use match-record instead of using accessors
> as it results in much less code to type.
>
>> + #:environment-variables
>> + (append (list "CONFIG_VOLUME=/var/cache/whoogle-search")
>> + (default-environment-variables))))
>
> Is (default-environment-variables) necessary?
>
>> + (stop #~(make-kill-destructor))
>> + (documentation "Run a @code{whoogle-search} instance."))))
>> +
>> +(define (whoogle-profile-service config)
>> + (list
>> + (whoogle-configuration-whoogle config)))
>
> [...]
>
>> +
>> +(define whoogle-service-type
>> + (service-type
>> + (name 'whoogle-search)
>> + (extensions
>> + (list
>> + (service-extension
>> + shepherd-root-service-type
>> + whoogle-shepherd-service)
>> + (service-extension
>> + profile-service-type
>> + whoogle-profile-service)))
>
> You can use match-record here or use the accessor here instead.
> (e.g., (compose list whoogle-configuration-package))
>
>
> Could you add a system test for this service as well?
> It makes things easier to check and maintain.
>
>
> Cheers,
> Bruno
M
M
Miguel Ángel Moreno wrote on 9 Jun 2023 23:07
(address . 62102@debbugs.gnu.org)
863530fiq1.fsf@conses.eu
On 2023-06-09 23:03, Ludovic Courtès wrote:

Toggle quote (7 lines)
> Hi conses,
>
> Did you have a chance to look into Bruno’s suggestions below?
>
> Please let us know what you think.
>

Hey Ludovic,

Yes, I've noted them but I haven't gotten around to implementing them
yet. I'll give this a shot soon.

Toggle quote (88 lines)
>
> Bruno Victal <mirai@makinata.eu> skribis:
>
>> Hi,
>>
>> On 2023-03-10 20:11, conses wrote:
>>>
>>> + whoogle-service-type
>>> + whoogle-configuration
>>> +
>>
>> [...]
>>
>>> patchwork-database-configuration
>>> patchwork-database-configuration?
>>> patchwork-database-configuration-engine
>>> @@ -1575,6 +1580,47 @@ (define varnish-service-type
>>> (default-value
>>> (varnish-configuration))))
>>>
>>> +
>>
>> Missing page-break character here?
>> If you're using Emacs you can insert one with C-q C-l.
>>
>>> +;;;
>>> +;;; Whoogle
>>> +;;;
>>> +
>>> +(define-configuration/no-serialization whoogle-configuration
>>> + (whoogle
>>> + (package whoogle-search)
>>> + "The @code{whoogle-search} package to use."))
>>
>> I prefer this field to be named 'package' instead, to make it less prone
>> to confusion. The accessor, whoogle-configuration-package, should be exported
>> as well.
>>
>>> +(define (whoogle-shepherd-service config)
>>> + (list
>>> + (shepherd-service
>>> + (provision '(whoogle-search))
>>> + (start #~(make-forkexec-constructor
>>> + (list (string-append #$(whoogle-configuration-whoogle config)
>>> + "/bin/whoogle-search"))
>>
>> In general, you may prefer to use match-record instead of using accessors
>> as it results in much less code to type.
>>
>>> + #:environment-variables
>>> + (append (list "CONFIG_VOLUME=/var/cache/whoogle-search")
>>> + (default-environment-variables))))
>>
>> Is (default-environment-variables) necessary?
>>
>>> + (stop #~(make-kill-destructor))
>>> + (documentation "Run a @code{whoogle-search} instance."))))
>>> +
>>> +(define (whoogle-profile-service config)
>>> + (list
>>> + (whoogle-configuration-whoogle config)))
>>
>> [...]
>>
>>> +
>>> +(define whoogle-service-type
>>> + (service-type
>>> + (name 'whoogle-search)
>>> + (extensions
>>> + (list
>>> + (service-extension
>>> + shepherd-root-service-type
>>> + whoogle-shepherd-service)
>>> + (service-extension
>>> + profile-service-type
>>> + whoogle-profile-service)))
>>
>> You can use match-record here or use the accessor here instead.
>> (e.g., (compose list whoogle-configuration-package))
>>
>>
>> Could you add a system test for this service as well?
>> It makes things easier to check and maintain.
>>
>>
>> Cheers,
>> Bruno

--
Best regards,
Miguel Ángel Moreno
L
L
Ludovic Courtès wrote on 8 Aug 2023 17:26
(name . Miguel Ángel Moreno)(address . contact@conses.eu)(address . 62102@debbugs.gnu.org)
878ralr1ww.fsf_-_@gnu.org
Hey,

Miguel Ángel Moreno <contact@conses.eu> skribis:

Toggle quote (14 lines)
> On 2023-06-09 23:03, Ludovic Courtès wrote:
>
>> Hi conses,
>>
>> Did you have a chance to look into Bruno’s suggestions below?
>>
>> Please let us know what you think.
>>
>
> Hey Ludovic,
>
> Yes, I've noted them but I haven't gotten around to implementing them
> yet. I'll give this a shot soon.

Friendly ping! :-)

Ludo’.
M
M
Miguel Ángel Moreno wrote on 13 Aug 2023 12:37
[PATCH v2] services: Add whoogle-service-type.
(address . 62102@debbugs.gnu.org)
864jl344a7.fsf@migalmoreno.com
* gnu/services/web.scm (whoogle-service-type): New variable.
* doc/guix.texi (Web Services): Document it.
---
doc/guix.texi | 32 +++++++++++++++++++++++++
gnu/services/web.scm | 56 ++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 88 insertions(+)

Toggle diff (144 lines)
diff --git a/doc/guix.texi b/doc/guix.texi
index 409ca2ad62..35746ec21e 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -31031,6 +31031,38 @@ Web Services
@end table
@end deftp
+@subheading Whoogle Search
+@cindex Whoogle Search
+@uref{https://github.com/benbusby/whoogle-search, Whoogle Search} is a
+self-hosted, ad-free, privacy-respecting metasearch engine that collects
+and displays Google search results.
+
+@defvar whoogle-service-type
+Service type for Whoogle Search.
+@end defvar
+
+@deftp {Data Type} whoogle-configuration
+Data type representing Whoogle Search service configuration.
+
+@table @asis
+@item @code{package} (default: @code{whoogle-search})
+The Whoogle Search package to use.
+
+@item @code{host} (default: @code{"127.0.0.1"})
+The host address to run Whoogle on.
+
+@item @code{port} (default: @code{5000})
+The port where Whoogle will be exposed.
+
+@item @code{environment-variables} (default: @code{'()})
+A list of strings with the environment variables to configure Whoogle.
+You can consult
+@uref{https://github.com/benbusby/whoogle-search/blob/main/whoogle.template.env,
+its environment variables template} for the list of available options.
+
+@end table
+@end deftp
+
@subsubheading Patchwork
@cindex Patchwork
Patchwork is a patch tracking system. It can collect patches sent to a
diff --git a/gnu/services/web.scm b/gnu/services/web.scm
index 818226a4f7..ed53572eec 100644
--- a/gnu/services/web.scm
+++ b/gnu/services/web.scm
@@ -16,6 +16,7 @@
;;; Copyright © 2020, 2021 Alexandru-Sergiu Marton <brown121407@posteo.ro>
;;; Copyright © 2022 Simen Endsjø <simendsjo@gmail.com>
;;; Copyright © 2023 Bruno Victal <mirai@makinata.eu>
+;;; Copyright © 2023 Miguel Ángel Moreno <mail@migalmoreno.com>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -36,6 +37,7 @@ (define-module (gnu services web)
#:use-module (gnu services)
#:use-module (gnu services shepherd)
#:use-module (gnu services admin)
+ #:use-module (gnu services configuration)
#:use-module (gnu services getmail)
#:use-module (gnu services mail)
#:use-module (gnu system pam)
@@ -47,6 +49,7 @@ (define-module (gnu services web)
#:use-module (gnu packages patchutils)
#:use-module (gnu packages php)
#:use-module (gnu packages python)
+ #:use-module (gnu packages python-web)
#:use-module (gnu packages gnupg)
#:use-module (gnu packages guile)
#:use-module (gnu packages logging)
@@ -240,6 +243,13 @@ (define-module (gnu services web)
varnish-service-type
+ whoogle-service-type
+ whoogle-configuration
+ whoogle-configuration-package
+ whoogle-configuration-host
+ whoogle-configuration-port
+ whoogle-configuration-environment-variables
+
patchwork-database-configuration
patchwork-database-configuration?
patchwork-database-configuration-engine
@@ -1604,6 +1614,52 @@ (define varnish-service-type
(default-value
(varnish-configuration))))
+
+;;;
+;;; Whoogle
+;;;
+
+(define-configuration/no-serialization whoogle-configuration
+ (package
+ (package whoogle-search)
+ "The @code{whoogle-search} package to use.")
+ (host
+ (string "127.0.0.1")
+ "The host address to run Whoogle on.")
+ (port
+ (integer 5000)
+ "The port to run Whoogle on.")
+ (environment-variables
+ (list-of-strings '())
+ "A list of strings specifying environment variables used to configure
+Whoogle."))
+
+(define (whoogle-shepherd-service config)
+ (match-record config <whoogle-configuration>
+ (package host port environment-variables)
+ (list
+ (shepherd-service
+ (provision '(whoogle-search))
+ (start #~(make-forkexec-constructor
+ (list (string-append #$package "/bin/whoogle-search")
+ "--host" #$host "--port" #$(number->string port))
+ #:environment-variables
+ (append (list "CONFIG_VOLUME=/var/cache/whoogle-search")
+ '#$environment-variables)))
+ (stop #~(make-kill-destructor))
+ (documentation "Run a @code{whoogle-search} instance.")))))
+
+(define whoogle-service-type
+ (service-type
+ (name 'whoogle-search)
+ (extensions
+ (list (service-extension shepherd-root-service-type
+ whoogle-shepherd-service)
+ (service-extension profile-service-type
+ (compose list whoogle-configuration-package))))
+ (default-value (whoogle-configuration))
+ (description "Set up the @code{whoogle-search} metasearch engine.")))
+
;;;
;;; Patchwork
--
2.41.0

--
Best regards,
Miguel Ángel Moreno
M
M
Miguel Ángel Moreno wrote on 13 Aug 2023 12:57
Re: bug#62102: [PATCH] services: Add whoogle-service-type.
(address . 62102@debbugs.gnu.org)
86wmxz2oru.fsf@migalmoreno.com
On 2023-08-08 17:26, Ludovic Courtès wrote:

Toggle quote (3 lines)
> Hey,
>

Hi Ludovic,

Toggle quote (11 lines)
> Miguel Ángel Moreno <contact@conses.eu> skribis:
>
>> On 2023-06-09 23:03, Ludovic Courtès wrote:
>>
>>> Hi conses,
>>>
>>> Did you have a chance to look into Bruno’s suggestions below?
>>>
>>> Please let us know what you think.
>>>

I addressed Bruno's points, added extra fields to configure this service
further, and documented these in the manual.

In regard to tests, I had a glance at ./tests/services/ to see what kind
of tests there were, and most them test serialization or some
service-specific feature. Since Whoogle is essentially a Flask web
application, I wouldn't know how to go about testing it in the context
of a service.

Other than that, happy to hear your feedback on the new revision :)

Toggle quote (10 lines)
>>
>> Hey Ludovic,
>>
>> Yes, I've noted them but I haven't gotten around to implementing them
>> yet. I'll give this a shot soon.
>
> Friendly ping! :-)
>
> Ludo’.

--
Best regards,
Miguel Ángel Moreno
M
M
Miguel Ángel Moreno wrote on 11 Feb 21:34 +0100
(address . 62102@debbugs.gnu.org)
86h6iekaf0.fsf@migalmoreno.com
Hi,
Friendly ping on this patch :)
--
Best regards,
Miguel Ángel Moreno
L
L
Ludovic Courtès wrote on 19 Feb 22:25 +0100
Re: [bug#62102] [PATCH v2] services: Add whoogle-service-type.
(name . Miguel Ángel Moreno)(address . mail@migalmoreno.com)(address . 62102@debbugs.gnu.org)
8734toqh8j.fsf@gnu.org
Hi,

Miguel Ángel Moreno <mail@migalmoreno.com> skribis:

Toggle quote (3 lines)
> * gnu/services/web.scm (whoogle-service-type): New variable.
> * doc/guix.texi (Web Services): Document it.

Finally applied! I followed up by expanding the Whoogle intro in the
manual a bit.

Things nice-to-have that come to mind:

• A system test. This is normally required for all new system
services. I was willing to make an exception here because it’s
already taken way too long, but would be nice to have such a test to
ensure the service actually keeps working.

• Running the daemon with ‘least-authority-wrapper’. It’s a good idea
for all network-facing daemons.

• Adding a Home service via ‘define-service-type-mapping’.

Thanks,
Ludo’.
L
L
Ludovic Courtès wrote on 19 Feb 22:25 +0100
control message for bug #62102
(address . control@debbugs.gnu.org)
871q98qh8a.fsf@gnu.org
close 62102
quit
?
Your comment

This issue is archived.

To comment on this conversation send an email to 62102@debbugs.gnu.org

To respond to this issue using the mumi CLI, first switch to it
mumi current 62102
Then, you may apply the latest patchset in this issue (with sign off)
mumi am -- -s
Or, compose a reply to this issue
mumi compose
Or, send patches to this issue
mumi send-email *.patch