From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp10.migadu.com ([2001:41d0:403:4789::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms9.migadu.com with LMTPS id WSZNKPAL0GSneAAASxT56A (envelope-from ) for ; Sun, 06 Aug 2023 23:09:04 +0200 Received: from aspmx1.migadu.com ([2001:41d0:403:4789::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp10.migadu.com with LMTPS id QPjXJvAL0GR9KwEAG6o9tA (envelope-from ) for ; Sun, 06 Aug 2023 23:09:04 +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 3148A4652B for ; Sun, 6 Aug 2023 23:09:04 +0200 (CEST) Authentication-Results: aspmx1.migadu.com; dkim=fail ("body hash did not verify") header.d=gnu.org header.s=fencepost-gnu-org header.b=BbHatuEg; 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=pass (policy=none) header.from=gnu.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1691356144; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: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=8P/7tJlUE5QX9sN8zEzT+etezPpTKyL1U4ZiYJp2Kuc=; b=bb8k0wpasO/WE83KMWZzE3+7ooxrx7lVXZooIPiOXnBCr7OwRVEb2AuS2p5eSyJR4+S0oR XVdEhixN9+zijFwyJQNCkZMDYbUCKnRjtSXLeKbpTk9zn3JtpSCg/f/g6eCMceA9iMUybV qSyNobQ9Iq+tZH9jNymMDin9CwVgCCI8HLhjpCjm2E/P7crO3VcpYeuCah98aTo2ApvkAl TKo3GawqHrqXG3E+UIeZrtxW6yI84qobgQvrdXv/DcsyTn0sUdugdLsTSAliBgphIkKjtD POL7hFQzFd08y6fKRDd1sIgEA2GMz/lc8VzeweT3P+9Qrm1o9Il/BQsNn1r9MA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("body hash did not verify") header.d=gnu.org header.s=fencepost-gnu-org header.b=BbHatuEg; 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=pass (policy=none) header.from=gnu.org ARC-Seal: i=1; s=key1; d=yhetil.org; t=1691356144; a=rsa-sha256; cv=none; b=KZ9kFPs232rLz3Ws23PArEjqItZdzF09ceqyV5y+1ZduC/ezHi6rbu9Dceq33tHasJqNXD J97uplxnfZ5trZvMudKrqXXxuiT8lPlEHsRBMTKyvcN3mqnluYji5RWa5+2Hpk++wylbtS liVM6ch4+7yIKx04qFG+ei8BtHljj/pxGlapwD5wNzayT5SX0NcsNhkk07G9iE+2vTyx1O eCWN821fI6Y+YrbHGme+8+R0ff+QHP1S9FQvguk36lWSRMx+M91OzQLd0V2YtVVFUV+qZP 0idFxXOkrhptcVEqXenVLPmE4lsoeAebRG4GYMQp2yPdtNsZayvo3uinRD48ow== Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qSkzm-0007Jk-Mc; Sun, 06 Aug 2023 17:09:02 -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 1qSkzm-0007JY-2V for guix-patches@gnu.org; Sun, 06 Aug 2023 17:09:02 -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 1qSkzl-0001XS-Qj for guix-patches@gnu.org; Sun, 06 Aug 2023 17:09:01 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qSkzl-0005kb-Kp for guix-patches@gnu.org; Sun, 06 Aug 2023 17:09: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: Ludovic =?UTF-8?Q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: , guix-patches@gnu.org Resent-Date: Sun, 06 Aug 2023 21:09: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: 65119@debbugs.gnu.org Cc: Ludovic =?UTF-8?Q?Court=C3=A8s?= , ( , Andrew Tropin , Ludovic =?UTF-8?Q?Court=C3=A8s?= X-Debbugs-Original-Xcc: ( , Andrew Tropin , Ludovic =?UTF-8?Q?Court=C3=A8s?= Received: via spool by 65119-submit@debbugs.gnu.org id=B65119.169135608722026 (code B ref 65119); Sun, 06 Aug 2023 21:09:01 +0000 Received: (at 65119) by debbugs.gnu.org; 6 Aug 2023 21:08:07 +0000 Received: from localhost ([127.0.0.1]:60138 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qSkys-0005jA-E5 for submit@debbugs.gnu.org; Sun, 06 Aug 2023 17:08:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54140) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qSkym-0005gp-Jv for 65119@debbugs.gnu.org; Sun, 06 Aug 2023 17:08:01 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qSkyh-0001Qc-Dz; Sun, 06 Aug 2023 17:07:55 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:References:In-Reply-To:Date:Subject:To: From; bh=ETOIUMrTkUZoCm7DeL/5iMayIzi3BLCgHYt6kxTyd5c=; b=BbHatuEglK5X3xGJ8rYV +/GBonmx7IY5v+J80dE67mtN+a2hj8S+8rx4zGOFi66Xp0yNoxFsLSu2RLux1Yvwanw+beXOOKu8o ewcg5m3lmDw6ZxUMtDaunMcJr6pl/oCqv/UoE4/3E2iusGxjGwf8wqbRxotEOtDvrkNiGF7M7vGf8 A2IXwqMSLQ3w2SySZoBQcLECSBObNl+lsbNut8UEhUecjFXw9nSc3MecEZ9NVzfmU4e8ab1xv6BcS q955PHdfTg+vLAb9ZVdNVsoJIO1qzw9SPZcpwG/0RqNUnG2yrjH2nOxBkDti7TOh7asxQaWq7OMLH WwDxEkj5sJUwhA==; From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Date: Sun, 6 Aug 2023 23:07:33 +0200 Message-ID: <319a7664fdf2b910f4183ce3c748234a8763e107.1691355218.git.ludo@gnu.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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-Queue-Id: 3148A4652B X-Migadu-Scanner: mx1.migadu.com X-Spam-Score: -1.36 X-Migadu-Spam-Score: -1.36 X-TUID: Wkhvds9YeQ8z * 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 © 2021, 2023 Andrew Tropin ;;; Copyright © 2021 Xinglu Chen ;;; Copyright © 2022 Maxim Cournoyer +;;; Copyright © 2023 Ludovic Courtès ;;; ;;; This file is part of GNU Guix. ;;; @@ -19,16 +20,9 @@ ;;; along with GNU Guix. If not, see . (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 mapping #:export (home-mcron-configuration home-mcron-service-type)) @@ -55,86 +49,16 @@ (define-module (gnu home services mcron) ;; ;;; Code: -(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 value -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.")) - -(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' 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) - #: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 ...))) (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))))) - -;;; -;;; Generate documentation. -;;; -(define (generate-doc) - (configuration->documentation 'home-mcron-configuration)) +(define-service-type-mapping + mcron-service-type => home-mcron-service-type) ;;; 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 © 2016, 2017, 2018, 2019, 2020 Ludovic Courtès +;;; Copyright © 2016-2020, 2023 Ludovic Courtès ;;; Copyright © 2022 Maxim Cournoyer ;;; Copyright © 2023 Bruno Victal ;;; @@ -20,10 +20,8 @@ (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? mcron-service-type)) @@ -55,40 +54,34 @@ (define-module (gnu services mcron) ;;; ;;; Code: -(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 -(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") + "/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)) -(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 value -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))) (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) (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-format - ,@(if (maybe-value-set? date-format) + ,@(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 config) jobs))))) (default-value (mcron-configuration)))) ;empty job list - -;;; -;;; Generate documentation. -;;; -(define (generate-doc) - (configuration->documentation 'mcron-configuration)) - ;;; mcron.scm ends here -- 2.41.0