diff mbox series

[bug#62465,v3,1/2] services: mcron: Add 'shepherd-requirement' field.

Message ID 4427884b06f47c6152b35e9559e6c1dc9412ebe5.1680185251.git.mirai@makinata.eu
State New
Headers show
Series [bug#62465,v3,1/2] services: mcron: Add 'shepherd-requirement' field. | expand

Commit Message

Bruno Victal March 30, 2023, 2:15 p.m. UTC
* gnu/services/mcron.scm (mcron-configuration)[shepherd-requirement]: New field.
(list-of-symbols?): New predicate.
(mcron-shepherd-services): Add support for additional shepherd requirements.
* doc/guix.texi (Scheduled Job Execution): Update it.

Notable changes from v2 to v3:
  Changing the final log-file value used in v2 behind the scenes
made it poorly reflexive as you couldn't trust what the accessors returned.
v3 makes log-file a mandatory field that has to be set manually and leaves
the default service instantiation responsible for setting the default log-file
that is used for the main mcron instance.

 doc/guix.texi          |  4 ++++
 gnu/services/mcron.scm | 13 +++++++++++--
 2 files changed, 15 insertions(+), 2 deletions(-)
diff mbox series


diff --git a/doc/guix.texi b/doc/guix.texi
index c49e51b72e..5a597cf122 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -19379,6 +19379,10 @@  Scheduled Job Execution
 @item @code{mcron} (default: @code{mcron}) (type: file-like)
 The mcron package to use.
+@item @code{shepherd-requirement} (default: @code{()}) (type: list-of-symbols)
+This is a list of symbols naming Shepherd services that this service
+will depend on.
 @item @code{jobs} (default: @code{()}) (type: list-of-gexps)
 This is a list of gexps (@pxref{G-Expressions}), where each gexp
 corresponds to an mcron job specification (@pxref{Syntax, mcron job
diff --git a/gnu/services/mcron.scm b/gnu/services/mcron.scm
index 2ef5980e09..99eb0edd60 100644
--- a/gnu/services/mcron.scm
+++ b/gnu/services/mcron.scm
@@ -32,6 +32,7 @@  (define-module (gnu services mcron)
   #:export (mcron-configuration
+            mcron-configuration-shepherd-requirement
@@ -58,6 +59,9 @@  (define-module (gnu services mcron)
 (define list-of-gexps?
   (list-of gexp?))
+(define list-of-symbols?
+  (list-of symbol?))
 (define-maybe/no-serialization string)
 (define-configuration/no-serialization mcron-configuration
@@ -65,6 +69,11 @@  (define-configuration/no-serialization mcron-configuration
    (file-like mcron)
    "The mcron package to use.")
+  (shepherd-requirement
+   (list-of-symbols '())
+   "This is a list of symbols naming Shepherd services that this service
+will depend on.")
    (list-of-gexps '())
    "This is a list of gexps (@pxref{G-Expressions}), where each gexp
@@ -158,13 +167,13 @@  (define (shepherd-schedule-action mcron files)
 (define (mcron-shepherd-services config)
   (match-record config <mcron-configuration>
-    (mcron jobs log? log-file log-format date-format)
+    (mcron shepherd-requirement jobs log? log-file log-format date-format)
     (if (eq? jobs '())
         '()                             ;nothing to do
         (let ((files (job-files mcron jobs)))
           (list (shepherd-service
                  (provision '(mcron))
-                 (requirement '(user-processes))
+                 (requirement `(user-processes ,@shepherd-requirement))
                  (modules `((srfi srfi-1)
                             (srfi srfi-26)
                             (ice-9 popen) ;for the 'schedule' action