From: Bruno Victal <mirai@makinata.eu>
To: 62169@debbugs.gnu.org
Cc: Bruno Victal <mirai@makinata.eu>
Subject: [bug#62169] [PATCH 2/3] services: mcron: Use match-record.
Date: Mon, 13 Mar 2023 19:30:49 +0000 [thread overview]
Message-ID: <691ab538c6a9ea4d62b9113416114d12ddca0d54.1678735825.git.mirai@makinata.eu> (raw)
In-Reply-To: <cover.1678734029.git.mirai@makinata.eu>
* gnu/services/mcron.scm (mcron-shepherd-services): Use match-record.
---
gnu/services/mcron.scm | 68 ++++++++++++++++++++----------------------
1 file 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 @@ (define (shepherd-schedule-action mcron 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)
--
2.39.1
next prev parent reply other threads:[~2023-03-13 19:31 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-13 19:02 [bug#62169] [PATCH 0/3] services: mcron: Make log-file and date-format configurable Bruno Victal
2023-03-13 19:30 ` [bug#62169] [PATCH 1/3] services: mcron: Restyle mcron-configuration Bruno Victal
2023-03-13 19:30 ` Bruno Victal [this message]
2023-03-13 19:30 ` [bug#62169] [PATCH 3/3] services: mcron: Add log-file and date-format fields Bruno Victal
2023-03-21 18:45 ` [bug#62169] [PATCH 0/3] services: mcron: Make log-file and date-format configurable Maxim Cournoyer
2023-03-21 18:51 ` bug#62169: " Maxim Cournoyer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://guix.gnu.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=691ab538c6a9ea4d62b9113416114d12ddca0d54.1678735825.git.mirai@makinata.eu \
--to=mirai@makinata.eu \
--cc=62169@debbugs.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/guix.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).