From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp12.migadu.com ([2001:41d0:403:478a::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms9.migadu.com with LMTPS id yOAdIHeI42Sh6AAASxT56A (envelope-from ) for ; Mon, 21 Aug 2023 17:53:27 +0200 Received: from aspmx1.migadu.com ([2001:41d0:403:478a::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp12.migadu.com with LMTPS id mMfkH3eI42Q4TwAAauVa8A (envelope-from ) for ; Mon, 21 Aug 2023 17:53:27 +0200 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id D5B3267ED7 for ; Mon, 21 Aug 2023 17:53:26 +0200 (CEST) Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=trop.in header.s=gm1 header.b=AEPPhb6u; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org"; dmarc=none ARC-Seal: i=1; s=key1; d=yhetil.org; t=1692633207; a=rsa-sha256; cv=none; b=AcJfzDq2Y/DOk7m2+mEy+zaBFkMT2Lae0CgPodHhnJOYpw08n0IKPJPNCCjlQMIux8slsy w8Haasn+7be6tIbGkxqGLv0mcWMjHjv83w7rMZ8t9PtN4oDCMXqwZqCD7rIfkK0aoaQWsy vK5HLwawnVXZhE2T4k2zclgfM4r5GIcwM39sQuLjWDMMCKl500naqLhKSxjOkIxWo0o+3i Y7UY7Q+BSou9IuyOMNC2+eXUYWnWM3dToufVM9vReR8CfnkXHfVC+nu6ZSN3TB4uZ0Pq81 8/cqgpDpajWmniGS+XClRTSanHtjcHEY3WnODozWxwInal18sjo3ITiCsZsG3Q== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=trop.in header.s=gm1 header.b=AEPPhb6u; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org"; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1692633207; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type:resent-cc:resent-from:resent-sender: resent-message-id:in-reply-to:in-reply-to:references:references: list-id:list-help:list-unsubscribe:list-subscribe:list-post: dkim-signature; bh=C/O5t5vKiV7xwaWPEToczdGdHqqXnbLQ4MaCogOKgnY=; b=uVb/5z7omsgoZ6oSxANflxas5/1DPdKoACffXQEYljcrjTPRsKMSyObqDcJI1o4mpVDFpR vrAT9t+BYs2sjcNu2kSo8m0Hkaf50uNU6KN7VjEYpBBSoE4JaKRIJh84o2F6QWauLS5Jos 0vdIxGI2kHv5Pn/PkO94i+q8UqlZdogfB6yBHrzwzHfh747jzwfuSmiNJeboBjMKiL3E56 CCpHSB3+ne8lxgJ/QUYuUD74QrkSjBqE5rLWjOb33IK3T6J/X8vy6DK8EXZ8Ge1q/sQhN2 RtXPYRGsWF3UocbcadIWLdlgUvP87r9qVPW76+PnMcEcXIOcPfPtfmgUMFLIuA== Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qY7DB-0000do-RX; Mon, 21 Aug 2023 11:53:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qY7DA-0000dZ-6T for guix-patches@gnu.org; Mon, 21 Aug 2023 11:53:00 -0400 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qY7D9-000836-Te for guix-patches@gnu.org; Mon, 21 Aug 2023 11:52:59 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qY7DB-0000rT-NR for guix-patches@gnu.org; Mon, 21 Aug 2023 11:53:01 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#65119] [PATCH 6/8] home: services: mcron: Define as a mapping of the system service. Resent-From: Andrew Tropin Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Mon, 21 Aug 2023 15:53:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 65119 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: Ludovic =?UTF-8?Q?Court=C3=A8s?= , 65119@debbugs.gnu.org Received: via spool by 65119-submit@debbugs.gnu.org id=B65119.16926331703292 (code B ref 65119); Mon, 21 Aug 2023 15:53:01 +0000 Received: (at 65119) by debbugs.gnu.org; 21 Aug 2023 15:52:50 +0000 Received: from localhost ([127.0.0.1]:57552 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qY7D0-0000r1-16 for submit@debbugs.gnu.org; Mon, 21 Aug 2023 11:52:50 -0400 Received: from relay8-d.mail.gandi.net ([2001:4b98:dc4:8::228]:42849) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qY7Cx-0000qg-Ow for 65119@debbugs.gnu.org; Mon, 21 Aug 2023 11:52:48 -0400 Received: by mail.gandi.net (Postfix) with ESMTPSA id 43C1C1BF204; Mon, 21 Aug 2023 15:52:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=trop.in; s=gm1; t=1692633159; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=C/O5t5vKiV7xwaWPEToczdGdHqqXnbLQ4MaCogOKgnY=; b=AEPPhb6u/WwHXn9tzGwG7ImUSa1eJlXEluIXq3eF87ZnKrgT7wpP5gXMk2d8QjI9Lg+o4P r7NBmqXmFngywe6K/3pfMJuwy+NhuvVh08rJvpPn4sWDgx5gwt6NR0V+A0RlfA0gCkrZlC PAbpNr2Q++S/Hcwi5FotjW0BF3fZPNQBk4EsDoKuDe3dUYT6Cn9Z20jZ4pzqZd9W684O7L lOUhj+fGLpy3cHB4zZCWrRD9EdihmSudxRZ8oOOOKXr5NzqxzQhCeiWj32ToRb32YWi3+g G5PTFYDfGnhV4/xrARgtm6OEzoyVg5iv0I1ndvXcn8p2pTqmEFrUM00X9zGg7w== From: Andrew Tropin In-Reply-To: <319a7664fdf2b910f4183ce3c748234a8763e107.1691355218.git.ludo@gnu.org> References: <319a7664fdf2b910f4183ce3c748234a8763e107.1691355218.git.ludo@gnu.org> Date: Mon, 21 Aug 2023 19:50:23 +0400 Message-ID: <87o7j0gzsw.fsf@trop.in> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha512; protocol="application/pgp-signature" X-GND-Sasl: andrew@trop.in X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: guix-patches-bounces+larch=yhetil.org@gnu.org X-Migadu-Flow: FLOW_IN X-Migadu-Country: US X-Migadu-Scanner: mx0.migadu.com X-Spam-Score: -4.40 X-Migadu-Queue-Id: D5B3267ED7 X-Migadu-Spam-Score: -4.40 X-TUID: dE+g1DXRZwUB --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 2023-08-06 23:07, Ludovic Court=C3=A8s wrote: > * gnu/services/mcron.scm (list-of-gexps?): Remove. > (): Rewrite using 'define-record-type*'. > [home-service?]: New field. > [log-file]: Make thunked and changed default value. > (mcron-shepherd-services): Honor 'home-service?' and remove use of > 'maybe-value-set?'. > (mcron-service-type): Inherit 'home-service?' from CONFIG. > (generate-doc): Remove. > * gnu/home/services/mcron.scm (list-of-gexp?) > (, job-files, shepherd-schedule-action) > (home-mcron-shepherd-services, home-mcron-profile) > (home-mcron-extend, generate-doc): Remove. > (home-mcron-configuration): Turn into a macro. > (home-mcron-service-type): Define in terms of > 'system->home-service-type'. > : Add service type mapping. > --- > gnu/home/services/mcron.scm | 96 ++++--------------------------------- > gnu/services/mcron.scm | 80 ++++++++++++++----------------- > 2 files changed, 45 insertions(+), 131 deletions(-) > > diff --git a/gnu/home/services/mcron.scm b/gnu/home/services/mcron.scm > index f51edd6634..23be44ba07 100644 > --- a/gnu/home/services/mcron.scm > +++ b/gnu/home/services/mcron.scm > @@ -2,6 +2,7 @@ > ;;; Copyright =C2=A9 2021, 2023 Andrew Tropin > ;;; Copyright =C2=A9 2021 Xinglu Chen > ;;; Copyright =C2=A9 2022 Maxim Cournoyer > +;;; Copyright =C2=A9 2023 Ludovic Court=C3=A8s > ;;; > ;;; This file is part of GNU Guix. > ;;; > @@ -19,16 +20,9 @@ > ;;; along with GNU Guix. If not, see . >=20=20 > (define-module (gnu home services mcron) > - #:use-module (gnu packages guile-xyz) > #:use-module (gnu home services) > - #:use-module (gnu services configuration) > - #:use-module (gnu services shepherd) > #:use-module (gnu home services shepherd) > - #:use-module (guix records) > - #:use-module (guix gexp) > - #:use-module (srfi srfi-1) > - #:use-module (ice-9 match) > - > + #:use-module (gnu services mcron) ;for the service mappi= ng > #:export (home-mcron-configuration > home-mcron-service-type)) >=20=20 > @@ -55,86 +49,16 @@ (define-module (gnu home services mcron) > ;; > ;;; Code: >=20=20 > -(define list-of-gexps? > - (list-of gexp?)) > - > -(define-configuration/no-serialization home-mcron-configuration > - (mcron (file-like mcron) "The mcron package to use.") > - (jobs > - (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 > -specifications,, mcron, GNU@tie{}mcron}).") > - (log? (boolean #t) "Log messages to standard output.") > - (log-format > - (string "~1@*~a ~a: ~a~%") > - "@code{(ice-9 format)} format string for log messages. The default v= alue > -produces messages like \"@samp{@var{pid} @var{name}: > -@var{message}\"} (@pxref{Invoking mcron, Invoking,, mcron, GNU@tie{}mcro= n}). > -Each message is also prefixed by a timestamp by GNU Shepherd.")) > - > -(define job-files (@@ (gnu services mcron) job-files)) > -(define shepherd-schedule-action > - (@@ (gnu services mcron) shepherd-schedule-action)) > - > -(define (home-mcron-shepherd-services config) > - (match-record config > - (mcron jobs log? log-format) > - (if (null? jobs) > - '() ;no jobs to run > - (let ((files (job-files mcron jobs))) > - (list (shepherd-service > - (documentation "User cron jobs.") > - (provision '(mcron)) > - (modules `((srfi srfi-1) > - (srfi srfi-26) > - (ice-9 popen) ;for the 'schedule' ac= tion > - (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) > - #:log-file (string-append > - (or (getenv "XDG_STATE_HOME") > - (format #f "~a/.local/state" > - (getenv "HOME"))) > - "/log/mcron.log"))) > - (stop #~(make-kill-destructor)) > - (actions > - (list (shepherd-schedule-action mcron files))))))))) > - > -(define home-mcron-profile (compose list home-mcron-configuration-mcron)) > - > -(define (home-mcron-extend config jobs) > - (home-mcron-configuration > - (inherit config) > - (jobs (append (home-mcron-configuration-jobs config) > - jobs)))) > +(define-syntax-rule (home-mcron-configuration fields ...) > + ;; Macro provided for backward compatibility. > + (for-home (mcron-configuration fields ...))) >=20=20 > (define home-mcron-service-type > - (service-type (name 'home-mcron) > - (extensions > - (list (service-extension > - home-shepherd-service-type > - home-mcron-shepherd-services) > - (service-extension > - home-profile-service-type > - home-mcron-profile))) > - (compose concatenate) > - (extend home-mcron-extend) > - (default-value (home-mcron-configuration)) > - (description > - "Install and configure the GNU mcron cron job manager."= ))) > + (service-type > + (inherit (system->home-service-type mcron-service-type)) > + (default-value (for-home (mcron-configuration))))) >=20=20 > - > -;;; > -;;; Generate documentation. > -;;; > -(define (generate-doc) > - (configuration->documentation 'home-mcron-configuration)) > +(define-service-type-mapping > + mcron-service-type =3D> home-mcron-service-type) >=20=20 > ;;; mcron.scm ends here > diff --git a/gnu/services/mcron.scm b/gnu/services/mcron.scm > index 2ef5980e09..db8b539ff5 100644 > --- a/gnu/services/mcron.scm > +++ b/gnu/services/mcron.scm > @@ -1,5 +1,5 @@ > ;;; GNU Guix --- Functional package management for GNU > -;;; Copyright =C2=A9 2016, 2017, 2018, 2019, 2020 Ludovic Court=C3=A8s <= ludo@gnu.org> > +;;; Copyright =C2=A9 2016-2020, 2023 Ludovic Court=C3=A8s > ;;; Copyright =C2=A9 2022 Maxim Cournoyer > ;;; Copyright =C2=A9 2023 Bruno Victal > ;;; > @@ -20,10 +20,8 @@ >=20=20 > (define-module (gnu services mcron) > #:use-module (gnu services) > - #:use-module (gnu services configuration) > #:use-module (gnu services shepherd) > #:use-module (gnu packages guile-xyz) > - #:use-module (guix deprecation) > #:use-module (guix records) > #:use-module (guix gexp) > #:use-module (srfi srfi-1) > @@ -37,6 +35,7 @@ (define-module (gnu services mcron) > mcron-configuration-log-file > mcron-configuration-log-format > mcron-configuration-date-format > + mcron-configuration-home-service? >=20=20 > mcron-service-type)) >=20=20 > @@ -55,40 +54,34 @@ (define-module (gnu services mcron) > ;;; > ;;; Code: >=20=20 > -(define list-of-gexps? > - (list-of gexp?)) > +;; Configuration of mcron. > +;; XXX: 'define-configuration' cannot be used here due to the need for > +;; 'thunked' and 'innate' fields as well as 'this-mcron-configuration'. > +(define-record-type* mcron-configuration > + make-mcron-configuration > + mcron-configuration? > + this-mcron-configuration >=20=20 > -(define-maybe/no-serialization string) > + (mcron mcron-configuration-mcron ;file-like > + (default mcron)) > + (jobs mcron-configuration-jobs ;list of gexps > + (default '())) > + (log? mcron-configuration-log? ;Boolean > + (default #t)) > + (log-file mcron-configuration-log-file ;string | gexp > + (thunked) > + (default > + (if (mcron-configuration-home-service? > + this-mcron-configuration) > + #~(string-append %user-log-dir "/mcron.log") It seems that (modules `((shepherd support))) is missing for this line to work. > + "/var/log/mcron.log"))) > + (log-format mcron-configuration-log-format ;string > + (default "~1@*~a ~a: ~a~%")) > + (date-format mcron-configuration-date-format ;string | #f > + (default #f)) >=20=20 > -(define-configuration/no-serialization mcron-configuration > - (mcron > - (file-like mcron) > - "The mcron package to use.") > - > - (jobs > - (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 > -specifications,, mcron, GNU@tie{}mcron}).") > - > - (log? > - (boolean #t) > - "Log messages to standard output.") > - > - (log-file > - (string "/var/log/mcron.log") > - "Log file location.") > - > - (log-format > - (string "~1@*~a ~a: ~a~%") > - "@code{(ice-9 format)} format string for log messages. The default v= alue > -produces messages like @samp{@var{pid} @var{name}: @var{message}} > -(@pxref{Invoking mcron, Invoking,, mcron, GNU@tie{}mcron}). > -Each message is also prefixed by a timestamp by GNU Shepherd.") > - > - (date-format > - maybe-string > - "@code{(srfi srfi-19)} format string for date.")) > + (home-service? mcron-configuration-home-service? > + (default for-home?) (innate))) >=20=20 > (define (job-files mcron jobs) > "Return a list of file-like object for JOBS, a list of gexps." > @@ -158,13 +151,15 @@ (define (shepherd-schedule-action mcron files) >=20=20 > (define (mcron-shepherd-services config) > (match-record config > - (mcron jobs log? log-file log-format date-format) > + (mcron jobs log? log-file log-format date-format home-service?) > (if (eq? jobs '()) > '() ;nothing to do > (let ((files (job-files mcron jobs))) > (list (shepherd-service > (provision '(mcron)) > - (requirement '(user-processes)) > + (requirement (if home-service? > + '() > + '(user-processes))) > (modules `((srfi srfi-1) > (srfi srfi-26) > (ice-9 popen) ;for the 'schedule' action > @@ -175,7 +170,7 @@ (define (mcron-shepherd-services config) > (list #$(file-append mcron "/bin/mcron") > #$@(if log? > `("--log" "--log-format" ,log-fo= rmat > - ,@(if (maybe-value-set? date-f= ormat) > + ,@(if date-format > (list "--date-format" > date-format) > '())) > @@ -209,15 +204,10 @@ (define mcron-service-type > (extend (lambda (config jobs) > (mcron-configuration > (inherit config) > + (home-service? > + (mcron-configuration-home-service? config)) > (jobs (append (mcron-configuration-jobs confi= g) > jobs))))) > (default-value (mcron-configuration)))) ;empty job list >=20=20 > - > -;;; > -;;; Generate documentation. > -;;; > -(define (generate-doc) > - (configuration->documentation 'mcron-configuration)) > - > ;;; mcron.scm ends here =2D-=20 Best regards, Andrew Tropin --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEEKEGaxlA4dEDH6S/6IgjSCVjB3rAFAmTjh78ACgkQIgjSCVjB 3rAaMg/+PIW0DJ5NyaJtIUZzCT+YaAaTdE0ZQ8pRbuSqZLZb/zQXdGYgb2wRPKvL vpL16XYqiJgj4irXkJLORPp9dNvaUlNjNHToBN4CHOSs17+UUGFa988WxYIc8OA/ v/4p9FwSoW4e8O7lCVj5OQUh03N3AVJrMvyumDuGt/d+lgZUBxKe6R5E5OYa5wF6 vu1C5bgCRB0b46m0nVWtrX2devGAQYTSo1k52BCAnD6ffWLam91hXVKVYkWppckr dDweIlzE+qx3CE7cAF8TpfIGge0A8aj+AzyiHkSJDuWrSQkMtPGyYENPJZzELr0s swollJEdJ4/8WbfAh9kt+2UCY0uYeCT9h31kULV+j4j0WiWo0pXTwoPLi+BMrmxI o1XwicRHgovP+LuhvaV7YpPCyYR5GocRt/8VMrEW9xDrUOTm44BrcKODU+CmYiIF pCVUndhGcj4jeggA5nO5gfBZHIw8b8G/2kyuN9wDu1kMZh/Ua7qqGcfz/K8oFZrC 3f647oAfFNZ3O9QSOrIFe3k4EtrSwoSNJj3TxjcJ11dgyln9/zWzH8m4k7t2aCTq rv5kqBwvsJ2XX/xcGIR/18AUKiDcozeKm/kzytUFaEJefrFp31cK7FQ0ADlgfU54 9LUr9uXD5iaRxBSBq4p1/gKzg/Bra9sbUwYO189U5PBnuq9PEZ8= =eEtZ -----END PGP SIGNATURE----- --=-=-=--