aboutsummaryrefslogtreecommitdiff
path: root/gnu/services/mcron.scm
diff options
context:
space:
mode:
authorBruno Victal <mirai@makinata.eu>2023-03-13 19:30:49 +0000
committerMaxim Cournoyer <maxim.cournoyer@gmail.com>2023-03-21 14:31:22 -0400
commitedb398449f72d95334f78661b74fb9d0c9148eab (patch)
tree364bb4d9f81910aff7dd0950640305dec24cd6d4 /gnu/services/mcron.scm
parent6f4fd8f5b87d9f55013c91ecc3b92fc43269599e (diff)
downloadguix-edb398449f72d95334f78661b74fb9d0c9148eab.tar
guix-edb398449f72d95334f78661b74fb9d0c9148eab.tar.gz
services: mcron: Use match-record.
* gnu/services/mcron.scm (mcron-shepherd-services): Use match-record. Signed-off-by: Maxim Cournoyer <maxim.cournoyer@gmail.com>
Diffstat (limited to 'gnu/services/mcron.scm')
-rw-r--r--gnu/services/mcron.scm68
1 files changed, 33 insertions, 35 deletions
diff --git a/gnu/services/mcron.scm b/gnu/services/mcron.scm
index 6ee333f253..9f3afecf62 100644
--- a/gnu/services/mcron.scm
+++ b/gnu/services/mcron.scm
@@ -143,41 +143,39 @@ files."
(display line)
(loop)))))))))
-(define mcron-shepherd-services
- (match-lambda
- (($ <mcron-configuration> mcron ()) ;nothing to do!
- '())
- (($ <mcron-configuration> mcron jobs log? log-format)
- (let ((files (job-files mcron jobs)))
- (list (shepherd-service
- (provision '(mcron))
- (requirement '(user-processes))
- (modules `((srfi srfi-1)
- (srfi srfi-26)
- (ice-9 popen) ;for the 'schedule' action
- (ice-9 rdelim)
- (ice-9 match)
- ,@%default-modules))
- (start #~(make-forkexec-constructor
- (list (string-append #$mcron "/bin/mcron")
- #$@(if log?
- #~("--log" "--log-format" #$log-format)
- #~())
- #$@files)
-
- ;; Disable auto-compilation of the job files and set a
- ;; sane value for 'PATH'.
- #:environment-variables
- (cons* "GUILE_AUTO_COMPILE=0"
- "PATH=/run/current-system/profile/bin"
- (remove (cut string-prefix? "PATH=" <>)
- (environ)))
-
- #:log-file "/var/log/mcron.log"))
- (stop #~(make-kill-destructor))
-
- (actions
- (list (shepherd-schedule-action mcron files)))))))))
+(define (mcron-shepherd-services config)
+ (match-record config <mcron-configuration> (mcron jobs log? log-format)
+ (if (eq? jobs '())
+ '() ; nothing to do
+ (let ((files (job-files mcron jobs)))
+ (list (shepherd-service
+ (provision '(mcron))
+ (requirement '(user-processes))
+ (modules `((srfi srfi-1)
+ (srfi srfi-26)
+ (ice-9 popen) ;for the 'schedule' action
+ (ice-9 rdelim)
+ (ice-9 match)
+ ,@%default-modules))
+ (start #~(make-forkexec-constructor
+ (list (string-append #$mcron "/bin/mcron")
+ #$@(if log?
+ #~("--log" "--log-format" #$log-format)
+ #~())
+ #$@files)
+
+ ;; Disable auto-compilation of the job files and
+ ;; set a sane value for 'PATH'.
+ #:environment-variables
+ (cons* "GUILE_AUTO_COMPILE=0"
+ "PATH=/run/current-system/profile/bin"
+ (remove (cut string-prefix? "PATH=" <>)
+ (environ)))
+
+ #:log-file "/var/log/mcron.log"))
+ (stop #~(make-kill-destructor))
+ (actions
+ (list (shepherd-schedule-action mcron files)))))))))
(define mcron-service-type
(service-type (name 'mcron)