From patchwork Sat Mar 15 21:37:10 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: 40225 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 3856B27BBEC; Sat, 15 Mar 2025 21:39:54 +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=ham 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 8E2FB27BBE2 for ; Sat, 15 Mar 2025 21:39:53 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ttZDl-0004tz-IH; Sat, 15 Mar 2025 17:39:05 -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 1ttZDi-0004tZ-RH for guix-patches@gnu.org; Sat, 15 Mar 2025 17:39: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 1ttZDi-0002mG-EK; Sat, 15 Mar 2025 17:39:02 -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=l4JVBgpTFUvjF2wVzspUV72xkD12SP8VYV0Bj+Bh2kA=; b=gVOaVe5l9o1v1Y65p6bENEozyHE52xyxRZ3oMZkbCfO/yviTqUCFkhq8H5bHQDP8W8aQeFmJKz24Z7zThARMo5D0Is9E+z9LNXB8KdKi1rOXQpbU7qShOvTRfLOqSWK9HJXXpD37POgGp4BK5eV57XjBDfgtQfzCv8sBfOfDfgCzF79wg1y5KWE22gM0ZBD68ahBKYaxLkVXz6MrNf8MtdTW9jXOH96dVvy3TCFBgxsUonQjFddJBpi4RtOX5wiGww8JVpnL4+SThXQKn3Jk53HUQbgh9GHaAs8nLX9AtEN/1+qzyEXASivo3IDa+F4K+Zo7lCKzlLyJNf9XLi0oEg==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ttZDi-0004Ul-6f; Sat, 15 Mar 2025 17:39:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#77041] [PATCH 04/16] services: package-database: 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, 15 Mar 2025 21:39:02 +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.174207470217003 (code B ref 77041); Sat, 15 Mar 2025 21:39:02 +0000 Received: (at 77041) by debbugs.gnu.org; 15 Mar 2025 21:38:22 +0000 Received: from localhost ([127.0.0.1]:43843 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ttZCy-0004PQ-4f for submit@debbugs.gnu.org; Sat, 15 Mar 2025 17:38:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53280) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1ttZCj-0004Lo-2h for 77041@debbugs.gnu.org; Sat, 15 Mar 2025 17:38: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 1ttZCd-0002gQ-Ko; Sat, 15 Mar 2025 17:37: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=l4JVBgpTFUvjF2wVzspUV72xkD12SP8VYV0Bj+Bh2kA=; b=hBQT0Z2oXjrC2/ZdyjC/ jA/sznHLXGCDhLsOTT6/72/qQ54tTvg0GVqFxYEGi493ttzJFozrQLRwFbAFJ3XxU4+Xa+hY/ujb0 drVG+2+tJU46dKxHDAA9avTd1Li7G1dgL2CJlcm5JEU/E0rq4rf7L11mF/nHCxy7LMppL40Pdxu2p D2ao/LDrdZYpSGjOfly9OsVfgCfQ3aYD4xBe0k7RbXh+HNn9SBDyuJdcVn5uISmzl4Akee5OJtzDE xjVCad/m3qLsM/2ME2PeMjN0WRNuXcbReanvPxNF6uWVDhmW2aioAdkwY1jDImWVHY5uemzE2ucHg HF4eH2XhodsP3A==; From: Ludovic =?utf-8?q?Court=C3=A8s?= Date: Sat, 15 Mar 2025 22:37:10 +0100 Message-ID: <1344bace2389f90a2aa26834ab4b0528e55e2c30.1742073920.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/admin.scm (package-database-mcron-jobs): Rename to… (package-database-shepherd-services): … this. Return a shepherd service. (package-database-service-type): Update accordingly. * doc/guix.texi (File Search Services): Update documentation of the ‘schedule’ field. Change-Id: Id7b4c5cff95a7117dca7d95af37db7389bb5ca92 --- doc/guix.texi | 7 ++++--- gnu/services/admin.scm | 34 ++++++++++++++++++++++++---------- 2 files changed, 28 insertions(+), 13 deletions(-) diff --git a/doc/guix.texi b/doc/guix.texi index ae7b08ad23..e45e8a9979 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -27194,9 +27194,10 @@ File Search Services The Guix package to use. @item @code{schedule} (default: @code{%default-package-database-update-schedule}) -String or G-exp denoting an mcron schedule for the periodic -@command{guix locate --update} job (@pxref{Guile Syntax,,, mcron, -GNU@tie{}mcron}). +This is the schedule of the periodic @command{guix locate --update} job, +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}). @item @code{method} (default: @code{'store}) Indexing method for @command{guix locate}. The default value, diff --git a/gnu/services/admin.scm b/gnu/services/admin.scm index b73accc4af..e473794043 100644 --- a/gnu/services/admin.scm +++ b/gnu/services/admin.scm @@ -529,23 +529,37 @@ (define-configuration/no-serialization package-database-configuration "G-exp denoting the channels to use when updating the database (@pxref{Channels}).")) -(define (package-database-mcron-jobs configuration) +(define (package-database-shepherd-services configuration) (match-record configuration (package schedule method channels) (let ((channels (scheme-file "channels.scm" channels))) - (list #~(job #$schedule - ;; XXX: The whole thing's running as "root" just because it - ;; needs write access to /var/cache/guix/locate. - (string-append #$(file-append package "/bin/guix") - " time-machine -C " #$channels - " -- locate --update --method=" - #$(symbol->string method))))))) + (list (shepherd-service + (provision '(package-database-update)) + (requirement '(user-processes guix-daemon)) + (modules '((shepherd service timer))) + ;; XXX: The whole thing's running as "root" just because it needs + ;; write access to /var/cache/guix/locate. + (start #~(make-timer-constructor + #$(if (string? schedule) + #~(cron-string->calendar-event #$schedule) + schedule) + (command '(#$(file-append package "/bin/guix") + "time-machine" "-C" #$channels + "--" "locate" "--update" + #$(string-append + "--method=" (symbol->string method)))) + #:wait-for-termination? #t)) + (stop #~(make-timer-destructor)) + (documentation + "Periodically update the system-wide package database that can +be queried by the 'guix locate' command.") + (actions (list shepherd-trigger-action))))))) (define package-database-service-type (service-type (name 'package-database) - (extensions (list (service-extension mcron-service-type - package-database-mcron-jobs))) + (extensions (list (service-extension shepherd-root-service-type + package-database-shepherd-services))) (description "Periodically update the package database used by the @code{guix locate} command, which lets you search for packages that provide a given file.")