From patchwork Sat Mar 22 11:36:41 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: 40592 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 7229E27BBE2; Sat, 22 Mar 2025 11:38:45 +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 10B8127BBE2 for ; Sat, 22 Mar 2025 11:38:45 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tvxBL-00021s-RE; 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-0001l7-ML 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 1tvxAx-00006W-Ml; Sat, 22 Mar 2025 07:38:03 -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=PgbqXgtoTexWfVBvbRDW/xq0s5T6dJftZNFqA/+l6bY=; b=YuGkqC1toPKReFxiIPNXZg60bo01j0dQkh/A1bcG2BoZLofEvGki6qrbkR8+VVQt6r+iL2/lU17ZmnWX29HZCEztKivFGQbyiZT3uBDnAw9sY7qM/aGLzSfUUL1mYcVB71fe21viHk7UqJOAgVGl/ViSoQ4FqS6h1I0LG51NZ00oBA4OAusETFZGcU6ExJF+WOwbl9L2WVReMKPe0Ct+X+AAtso86EeOjIr2bI4wxbAWO0PixMBxdpdvJSyHlzTXpeEuLe8w7EM5SKkZHyJZ10srN183lzG41aDWXPLQQLBrmSrxg27vp7+mqM/KVWlCcLACDWaa8tHpd0G/KKkuwA==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tvxAx-0002Yb-Ha; Sat, 22 Mar 2025 07:38:03 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#77041] [PATCH v2 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, 22 Mar 2025 11:38:03 +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.17426434639674 (code B ref 77041); Sat, 22 Mar 2025 11:38:03 +0000 Received: (at 77041) by debbugs.gnu.org; 22 Mar 2025 11:37:43 +0000 Received: from localhost ([127.0.0.1]:41175 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tvxAc-0002Vx-QX for submit@debbugs.gnu.org; Sat, 22 Mar 2025 07:37:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44726) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1tvxAL-0002Tr-Sg for 77041@debbugs.gnu.org; Sat, 22 Mar 2025 07:37:26 -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 1tvxAG-0008TJ-K9; Sat, 22 Mar 2025 07:37:20 -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=PgbqXgtoTexWfVBvbRDW/xq0s5T6dJftZNFqA/+l6bY=; b=HJsjDl3H5Wvc/vTcJuTy m0qgGkp1z0hct6fdn+v9wTkq1/68yeXKdXPY5QzItH9+Pu8vzdrQyBlNP7MmfLQuRTw0/k699yQMD 8DIfK95J3pV87PxF1ECiDewUJphWRXbdg/9tevHs1+/l5bRikvK83HyCUW+NI7vbvG8tBWte1yMUy zvwj2cM20ncnDzf/s8JMU/X0keyANLOjOAPB20e2DVeBqRs1bStfAelTG7CfoT62GRPFPop+G3vaC yZk6Y0mXHmjL+PmHYgsrmPL14I9Dv2QzPEr2JoNAcxrx/oaBdGM59rEHDrXAB05UR5RlCTo1mFJIf YCF9AlXrPble+A==; From: Ludovic =?utf-8?q?Court=C3=A8s?= Date: Sat, 22 Mar 2025 12:36:41 +0100 Message-ID: <6cc6ca8950931518bab8c779466cd41770abbbdf.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/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 9e3b452577..eb0a18eff4 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -27204,9 +27204,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.")