From patchwork Sat Mar 22 11:36:42 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ludovic_Court=C3=A8s?= X-Patchwork-Id: 40591 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id C4B8527BBEB; Sat, 22 Mar 2025 11:38:40 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_BLOCKED, RCVD_IN_VALIDITY_CERTIFIED,RCVD_IN_VALIDITY_RPBL,RCVD_IN_VALIDITY_SAFE, SPF_HELO_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 3C9DC27BBE2 for ; Sat, 22 Mar 2025 11:38:39 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tvxBL-00021d-R4; Sat, 22 Mar 2025 07:38:28 -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 1tvxAz-0001lH-U1 for guix-patches@gnu.org; Sat, 22 Mar 2025 07:38:05 -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 1tvxAy-00006a-81; Sat, 22 Mar 2025 07:38:05 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:References:In-Reply-To:Date:From:To:Subject; bh=aZzbLgwecY8nnMYdKCGfSNoCUaCBO/u+0cJBIinqz0o=; b=rzzNWv4xExvGoI/jWcj7ipEekn2GN6WrjyCa5EDskETcd7ceHSSCf9q2nchcPIf37z3QOCQRzc4C3c9pkkSbROqITZwKa53vV1P6b58UJBzmGr9PvSXY55KLu0wiXGMlHzdOdnAxW/PKeWldCnq8Abca/q8jlJkfy1Awv3N+K8Ev+zO0S6TpgHcUlA8qHV6DUzW4W+OOGFOzeyqMHEnAiqcOw3Uw9O829HYS4S/elIjITucighQ60JgRTDTtbBuzoeKXUp5XwcqQzdeYgawTQ0aCgNCbutv7dy0ipJ8o1mUbDh86HRzLelyA9wmu5N4z0vwT+0BhzzgeNacHZODVTw==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tvxAy-0002Yj-1q; Sat, 22 Mar 2025 07:38:04 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#77041] [PATCH v2 05/16] services: fstrim: Turn into a Shepherd timer. Resent-From: Ludovic =?utf-8?q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: ludo@gnu.org, maxim.cournoyer@gmail.com, guix-patches@gnu.org Resent-Date: Sat, 22 Mar 2025 11:38:04 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 77041 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 77041@debbugs.gnu.org Cc: Ludovic =?utf-8?q?Court=C3=A8s?= , Ludovic =?utf-8?q?Court?= =?utf-8?q?=C3=A8s?= , Maxim Cournoyer X-Debbugs-Original-Xcc: Ludovic =?utf-8?q?Court=C3=A8s?= , Maxim Cournoyer Received: via spool by 77041-submit@debbugs.gnu.org id=B77041.17426434649682 (code B ref 77041); Sat, 22 Mar 2025 11:38:04 +0000 Received: (at 77041) by debbugs.gnu.org; 22 Mar 2025 11:37:44 +0000 Received: from localhost ([127.0.0.1]:41177 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tvxAd-0002Vz-AZ for submit@debbugs.gnu.org; Sat, 22 Mar 2025 07:37:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44734) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1tvxAM-0002Tu-V6 for 77041@debbugs.gnu.org; Sat, 22 Mar 2025 07:37:27 -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 1tvxAH-0008TS-Kl; Sat, 22 Mar 2025 07:37:21 -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=aZzbLgwecY8nnMYdKCGfSNoCUaCBO/u+0cJBIinqz0o=; b=I3R62rzVhH5G5wIr7POJ z3pInFmiT4pYH5z+sF8EVLnHB9OQMmnb0Y+yHbavqELpPyUMqaE1L94vzy+QpysJzSZS8PQMiy5va FmyKXAAa8fwxsLF6vDz1282rsDNB199kuIjqktejjEgSm6rwxD4raWts3LkWcJDWE/eqqRa3OtL5o 8n3k8sgM79FTrOglBUzd/37kS65Ky0aUoSFz06XdeRFTn0niF2YcQBHI3aPVnqdwDiXN28E77atUD Uj7lQ1HmWYx4CytAM2DUXCqIhFPQP/QoqZj+pUd8hzW1tVgV86BhhvngD7ff2lg2lIdyOGEPEIlhQ j75O2lhpZ8FnKw==; From: Ludovic =?utf-8?q?Court=C3=A8s?= Date: Sat, 22 Mar 2025 12:36:42 +0100 Message-ID: <3e855021731ed7877824270ff0faed6a523965ca.1742642743.git.ludo@gnu.org> X-Mailer: git-send-email 2.48.1 In-Reply-To: References: MIME-Version: 1.0 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+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches * gnu/services/linux.scm (mcron-time?): Remove. (shepherd-calendar-event?): New procedure. (fstrim-configuration)[schedule]: Change type to ‘shepherd-calendar-event’ and update docstring. (fstrim-mcron-job): Rename to… (fstrim-shepherd-services): … this. Return a list of Shepherd services. (fstrim-service-type): Adjust accordingly. * doc/guix.texi (Linux Services): Update. Change-Id: I9a7433cb15a1f4600470a915769d612e6e644dd8 --- doc/guix.texi | 14 +++++++----- gnu/services/linux.scm | 50 +++++++++++++++++++++++------------------- 2 files changed, 36 insertions(+), 28 deletions(-) diff --git a/doc/guix.texi b/doc/guix.texi index eb0a18eff4..e194919a9d 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -42118,6 +42118,7 @@ Linux Services @end defvar @c %start of fragment + @deftp {Data Type} fstrim-configuration Available @code{fstrim-configuration} fields are: @@ -42125,11 +42126,11 @@ Linux Services @item @code{package} (default: @code{util-linux}) (type: file-like) The package providing the @command{fstrim} command. -@item @code{schedule} (default: @code{"0 0 * * 0"}) (type: mcron-time) -Schedule for launching @command{fstrim}. This can be a procedure, a -list or a string. For additional information, see @ref{Guile -Syntax,,Job specification,mcron,the mcron manual}. By default this is -set to run weekly on Sunday at 00:00. +@item @code{schedule} (default: @code{"0 0 * * 0"}) (type: shepherd-calendar-event) +Schedule for launching @command{fstrim}, expressed as a string in +traditional cron syntax or as a gexp evaluating to a Shepherd calendar +event (@pxref{Timers,,, shepherd,The GNU Shepherd Manual}). By default +this is set to run weekly on Sunday at 00:00. @item @code{listed-in} (default: @code{'("/etc/fstab" "/proc/self/mountinfo")}) (type: maybe-list-of-strings) List of files in fstab or kernel mountinfo format. All missing or empty @@ -42148,7 +42149,10 @@ Linux Services more information). @end table + @end deftp + + @c %end of fragment @cindex modprobe diff --git a/gnu/services/linux.scm b/gnu/services/linux.scm index b22dbeefa0..d7aee1b82e 100644 --- a/gnu/services/linux.scm +++ b/gnu/services/linux.scm @@ -34,7 +34,6 @@ (define-module (gnu services linux) #:use-module (gnu services admin) #:use-module (gnu services base) #:use-module (gnu services configuration) - #:use-module (gnu services mcron) #:use-module (gnu services shepherd) #:use-module (gnu packages linux) #:use-module (srfi srfi-1) @@ -196,8 +195,8 @@ (define earlyoom-service-type ;;; fstrim ;;; -(define (mcron-time? x) - (or (procedure? x) (string? x) (list? x))) +(define (shepherd-calendar-event? x) + (or (string? x) (gexp? x))) (define-maybe list-of-strings (prefix fstrim-)) @@ -216,11 +215,11 @@ (define-configuration fstrim-configuration "The package providing the @command{fstrim} command." empty-serializer) (schedule - (mcron-time "0 0 * * 0") - "Schedule for launching @command{fstrim}. This can be a procedure, a list -or a string. For additional information, see @ref{Guile Syntax,, -Job specification, mcron, the mcron manual}. By default this is set to run -weekly on Sunday at 00:00." + (shepherd-calendar-event "0 0 * * 0") + "Schedule for launching @command{fstrim}, expressed as a string in +traditional cron syntax or as a gexp evaluating to a Shepherd calendar +event (@pxref{Timers,,, shepherd, The GNU Shepherd Manual}). By default this +is set to run weekly on Sunday at 00:00." empty-serializer) ;; The following are fstrim-related options. (listed-in @@ -251,26 +250,31 @@ (define (serialize-fstrim-configuration config) rcons fstrim-configuration-fields)) -(define (fstrim-mcron-job config) - (match-record config (package schedule) - #~(job - ;; Note: The “if” below is to ensure that - ;; lists are ungexp'd correctly since @var{schedule} - ;; can be either a procedure, a string or a list. - #$(if (list? schedule) - #~'(#$@schedule) - schedule) - (lambda () - (system* #$(file-append package "/sbin/fstrim") - #$@(serialize-fstrim-configuration config))) - "fstrim"))) +(define (fstrim-shepherd-services config) + (match-record config + (package schedule) + (list (shepherd-service + (provision '(fstrim)) + (requirement '(user-processes)) + (modules '((shepherd service timer))) + (start #~(make-timer-constructor + #$(if (string? schedule) + #~(cron-string->calendar-event #$schedule) + schedule) + (command + (list #$(file-append package "/sbin/fstrim") + #$@(serialize-fstrim-configuration config))) + #:wait-for-termination? #t)) + (stop #~(make-timer-destructor)) + (documentation "Periodically run the 'fstrim' command.") + (actions (list shepherd-trigger-action)))))) (define fstrim-service-type (service-type (name 'fstrim) (extensions - (list (service-extension mcron-service-type - (compose list fstrim-mcron-job)))) + (list (service-extension shepherd-root-service-type + fstrim-shepherd-services))) (description "Discard unused blocks from file systems.") (default-value (fstrim-configuration))))