From debbugs-submit-bounces@debbugs.gnu.org Wed Jul 05 06:00:17 2023 Received: (at submit) by debbugs.gnu.org; 5 Jul 2023 10:00:17 +0000 Received: from localhost ([127.0.0.1]:37127 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qGzJ3-0006Ha-4D for submit@debbugs.gnu.org; Wed, 05 Jul 2023 06:00:17 -0400 Received: from lists.gnu.org ([209.51.188.17]:60504) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qGzIz-0006HM-95 for submit@debbugs.gnu.org; Wed, 05 Jul 2023 06:00:15 -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 1qGzIy-0000ik-R9 for guix-patches@gnu.org; Wed, 05 Jul 2023 06:00:12 -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 1qGzIx-00044w-QK; Wed, 05 Jul 2023 06:00:11 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:Date:Subject:To:From:in-reply-to: references; bh=vu89Nnn4Y0L7ysm9HAOf6TPFKMQyE84l2Z/4CBKQqYg=; b=shxoKdCcTv/RQQ fQQc6XlGNJ3ZmM3lTq6bwbKpAJ0Mmg1f9L12bwByowJqjYv1J16d9cNa1qDn85wd9ERjWnr9mFZ6N MMYg7b2E4EMJahwpLvTeLPHlJhI9VKk63d47018E3VyGdEeacdcEFl/qk7eq/cF7sPuR/nZ39Xgg6 AEDptJUff6aqt2K6F8oEnoP8Bk9ehKsD84MxcKXfGJlV5sWZZ3yIrdpAnt5kw16LCvF01CsOfH9H3 egCd6kCGtQACivJwFVWXTwasX+X+1MRD+udLmfDI72QoD0MgwEUSQsmgFOyTsJBt7DQzScSGjnpNF Iq7GyCTlRGWJzEgLAPUw==; Received: from vpn-0-27.aquilenet.fr ([2a0c:e300:4:27::] helo=gnu.org) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qGzIw-00054v-2K; Wed, 05 Jul 2023 06:00:11 -0400 From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= To: guix-patches@gnu.org Subject: [PATCH 0/2] File database update services Date: Wed, 5 Jul 2023 11:59:44 +0200 Message-Id: X-Mailer: git-send-email 2.40.1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: submit Cc: =?UTF-8?q?Ludovic=20Court=C3=A8s?= X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Hi! These patches add two system services to periodically update file databases: one for 'updatedb', and one for 'guix locate --update'. I did not add them to '%base-services' mainly because: (1) 'updatedb' builds a database of all the files available on the system, which can be a problem on multi-user systems, and (2) the 'guix locate' service is quite expensive ('time-machine' + 'store' method by default) and eventually users may often download a pre-built database from ci.guix or similar. Thoughts? Ludo'. Ludovic Courtès (2): services: Add 'file-database' service. services: Add 'package-database' service. doc/guix.texi | 111 ++++++++++++++++++++++++++++++++++++++- gnu/services/admin.scm | 116 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 226 insertions(+), 1 deletion(-) base-commit: c4a836f65d178786a5dd1f7c2d9491bb2c7482b3 -- 2.40.1 From debbugs-submit-bounces@debbugs.gnu.org Wed Jul 05 06:17:01 2023 Received: (at 64471) by debbugs.gnu.org; 5 Jul 2023 10:17:01 +0000 Received: from localhost ([127.0.0.1]:37134 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qGzZE-0006hN-Ro for submit@debbugs.gnu.org; Wed, 05 Jul 2023 06:17:01 -0400 Received: from eggs.gnu.org ([209.51.188.92]:35300) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qGzZ9-0006h0-Vy for 64471@debbugs.gnu.org; Wed, 05 Jul 2023 06:16:59 -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 1qGzZ3-0007ZY-Si; Wed, 05 Jul 2023 06:16:49 -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=qMFxmGTTGQYZ5ZGiMjobtXAwePN9u3woQKT5aTBLUTM=; b=k6EcejhgH9PCdbAC1EfR rS6ZawRMW4Ofuun+z8KAzKKA9txqYCAoVFkbV3PTJj4u6zTAwyTEMQsQ34dHAMDPjy5N6bGjgBtcv gxOtn4BKFBlWDiQH0g/OaSP2b3PNe5dJI8yWZN+ATSMoLX/YEHXjgxcdQmrdCVPVuEgJqcISaOS/e GjNjDdbbdWLTIikI8olp/nAy3prItUFs81ouw26qavzp/UW8inkE8VkQkrzgO4hqiubkXOIawH6Js b77qFjfqPd7E9bVJgSB8R4isSyicKqwYYDqX0Q+JoDT39Fx3EWDKva4wy0G7KXww3OLIVDJJX6LKA vm4uPiBrBmvpzg==; Received: from vpn-0-27.aquilenet.fr ([185.233.101.27] helo=gnu.org) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qGzZ3-0008Gw-5Q; Wed, 05 Jul 2023 06:16:49 -0400 From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= To: 64471@debbugs.gnu.org Subject: [PATCH 1/2] services: Add 'file-database' service. Date: Wed, 5 Jul 2023 12:16:35 +0200 Message-Id: X-Mailer: git-send-email 2.40.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 64471 Cc: =?UTF-8?q?Ludovic=20Court=C3=A8s?= X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) * gnu/services/admin.scm (%default-file-database-update-schedule) (%default-file-database-excluded-directories): New variables. (): New record type. (file-database-mcron-jobs): New procedure. (file-database-service-type): New variable. * doc/guix.texi (File Search Services): New node. --- doc/guix.texi | 62 ++++++++++++++++++++++++++++++++++++++ gnu/services/admin.scm | 67 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 129 insertions(+) diff --git a/doc/guix.texi b/doc/guix.texi index 853396f776..21ff15ccbc 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -388,6 +388,7 @@ Top * Printing Services:: Local and remote printer support. * Desktop Services:: D-Bus and desktop services. * Sound Services:: ALSA and Pulseaudio services. +* File Search Services:: Tools to search for files. * Database Services:: SQL databases, key-value stores, etc. * Mail Services:: IMAP, POP3, SMTP, and all that. * Messaging Services:: Messaging services. @@ -18414,6 +18415,7 @@ Services * Printing Services:: Local and remote printer support. * Desktop Services:: D-Bus and desktop services. * Sound Services:: ALSA and Pulseaudio services. +* File Search Services:: Tools to search for files. * Database Services:: SQL databases, key-value stores, etc. * Mail Services:: IMAP, POP3, SMTP, and all that. * Messaging Services:: Messaging services. @@ -24924,6 +24926,66 @@ Sound Services @end defvar +@node File Search Services +@subsection File Search Services + +@cindex file search +@cindex searching for a file +The services in this section populate @dfn{file databases} that let you +search for files on your machine. These services are provided by the +@code{(gnu services admin)} module. + +The first one, @code{file-database-service-type}, periodically runs the +venerable @command{updatedb} command (@pxref{Invoking updatedb,,, find, +GNU Findutils}). That command populates a database of file names that +you can then search with the @command{locate} command (@pxref{Invoing +locate,,, find, GNU Findutils}), as in this example: + +@example +locate important-notes.txt +@end example + +You can enable this service with its default settings by adding this +snippet to your operating system services: + +@lisp +(service file-database-service-type) +@end lisp + +This updates the database once a week, excluding files from +@file{/gnu/store}---these are more usefully handled by @command{guix +locate} (@pxref{Invoking guix locate}). You can of course provide a +custom configuration, as described below. + +@defvar file-database-service-type +This is the type of the file database service, which runs +@command{updatedb} periodically. Its associated value must be a +@code{file-database-configuration} record, as described below. +@end defvar + +@deftp {Data Type} file-database-configuration +Record type for the @code{file-database-service-type} configuration, +with the following fields: + +@table @asis +@item @code{package} (default: @code{findutils}) +The GNU@tie{}Findutils package from which the @command{updatedb} command +is taken. + +@item @code{schedule} (default: @code{%default-file-database-update-schedule}) +String or G-exp denoting an mcron schedule for the periodic +@command{updatedb} job (@pxref{Guile Syntax,,, mcron, GNU@tie{}mcron}). + +@item @code{excluded-directories} (default @code{%default-file-database-excluded-directories}) +List of directories to ignore when building the file database. By +default, this includes @file{/tmp} and @file{/gnu/store}, which should +instead be indexed by @command{guix locate} (@pxref{Invoking guix +locate}). This list is passed to the @option{--prunepaths} option of +@command{updatedb} (@pxref{Invoking updatedb,,, find, +GNU@tie{}Findutils}). +@end table +@end deftp + @node Database Services @subsection Database Services diff --git a/gnu/services/admin.scm b/gnu/services/admin.scm index 1c10cfb1f6..57fdfc35c0 100644 --- a/gnu/services/admin.scm +++ b/gnu/services/admin.scm @@ -21,11 +21,14 @@ (define-module (gnu services admin) #:use-module (gnu packages admin) + #:use-module ((gnu packages base) + #:select (canonical-package findutils)) #:use-module (gnu packages certs) #:use-module (gnu packages package-management) #:use-module (gnu services) #:use-module (gnu services mcron) #:use-module (gnu services shepherd) + #:use-module ((guix store) #:select (%store-prefix)) #:use-module (guix gexp) #:use-module (guix modules) #:use-module (guix packages) @@ -55,6 +58,15 @@ (define-module (gnu services admin) log-cleanup-configuration-expiry log-cleanup-configuration-schedule + file-database-service-type + file-database-configuration + file-database-configuration? + file-database-configuration-package + file-database-configuration-schedule + file-database-configuration-excluded-directories + %default-file-database-update-schedule + %default-file-database-excluded-directories + unattended-upgrade-service-type unattended-upgrade-configuration unattended-upgrade-configuration? @@ -255,6 +267,61 @@ (define log-cleanup-service-type (description "Periodically delete old log files."))) + +;;; +;;; File databases. +;;; + +(define %default-file-database-update-schedule + ;; Default mcron schedule for the periodic 'updatedb' job: once every + ;; Sunday. + "10 23 * * 0") + +(define %default-file-database-excluded-directories + ;; Directories excluded from the 'locate' database. + (list (%store-prefix) + "/tmp" "/var/tmp" "/var/cache" ".*/\\.cache" + "/run/udev")) + +(define-record-type* + file-database-configuration make-file-database-configuration + file-database-configuration? + (package file-database-configuration-package + (default + (let-system (system target) + ;; Unless we're cross-compiling, avoid pulling a + ;; second copy of findutils. + (if target + findutils + (canonical-package findutils))))) + (schedule file-database-configuration-schedule + (default %default-file-database-update-schedule)) + (excluded-directories file-database-configuration-excluded-directories + (default %default-file-database-excluded-directories))) + +(define (file-database-mcron-jobs configuration) + (match-record configuration + (package schedule excluded-directories) + (let ((updatedb (program-file + "updatedb" + #~(execl #$(file-append package "/bin/updatedb") + "updatedb" + #$(string-append "--prunepaths=" + (string-join + excluded-directories)))))) + (list #~(job #$schedule #$updatedb))))) + +(define file-database-service-type + (service-type + (name 'file-database) + (extensions (list (service-extension mcron-service-type + file-database-mcron-jobs))) + (description + "Periodically update the file database used by the @command{locate} command, +which lets you search for files by name. The database is created by running +the @command{updatedb} command.") + (default-value (file-database-configuration)))) + ;;; ;;; Unattended upgrade. -- 2.40.1 From debbugs-submit-bounces@debbugs.gnu.org Wed Jul 05 06:17:05 2023 Received: (at 64471) by debbugs.gnu.org; 5 Jul 2023 10:17:05 +0000 Received: from localhost ([127.0.0.1]:37139 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qGzZI-0006i3-GA for submit@debbugs.gnu.org; Wed, 05 Jul 2023 06:17:04 -0400 Received: from eggs.gnu.org ([209.51.188.92]:35310) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qGzZF-0006hA-6m for 64471@debbugs.gnu.org; Wed, 05 Jul 2023 06:17:04 -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 1qGzZ9-0007a8-PZ; Wed, 05 Jul 2023 06:16: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=pOifxbrOgadiizlL4obmUKdtp1sQM3jW5yBflukXerA=; b=VprdfViCAiDM2rD4sZSE rLA70zlfIpZpMt5h16NIxEj+A04kffBOvb3n69Axvomg17vtm9ImHEEwxpD1blyWxoQgCw2/raC0n zKBMd21RL8urN1soU2+5iEyjoOD7U7sylM1o6eP3goO8jNu6QwM4gAgfFABor5CSNhQ8bscoz1jPr 9lxANODUK4JNTtilvARe/s67Lqs+WHmAy7/Axp+fro1XxTiSEG+PDNPs08MgK0PkJtIXDQhsGvTXc JboF0TjIJbi+1DNT3wAgCZaFznYmVLyni5gGNeBznkD+vTVWiDXYDcGlCRwT1O7sXr9Gf5bMGjiEA gQKJ9rXI/qIeqQ==; Received: from vpn-0-27.aquilenet.fr ([185.233.101.27] helo=gnu.org) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qGzZ7-0008Gw-Cp; Wed, 05 Jul 2023 06:16:55 -0400 From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= To: 64471@debbugs.gnu.org Subject: [PATCH 2/2] services: Add 'package-database' service. Date: Wed, 5 Jul 2023 12:16:36 +0200 Message-Id: X-Mailer: git-send-email 2.40.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 64471 Cc: =?UTF-8?q?Ludovic=20Court=C3=A8s?= X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) * gnu/services/admin.scm (%default-package-database-update-schedule): New variable. (): New record type. (package-database-mcron-jobs): New procedure. (package-database-service-type): New variable. * doc/guix.texi (File Search Services): Document it. --- doc/guix.texi | 49 +++++++++++++++++++++++++++++++++++++++++- gnu/services/admin.scm | 49 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 97 insertions(+), 1 deletion(-) diff --git a/doc/guix.texi b/doc/guix.texi index 21ff15ccbc..05cfdb9bc7 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -4481,7 +4481,9 @@ Invoking guix locate exist or is too old, it falls back to the per-user database, by default under @file{~/.cache/guix/locate}. On a multi-user system, administrators may want to periodically update the system-wide database -so that all users can benefit from it. +so that all users can benefit from it, for instance by setting up +@code{package-database-service-type} (@pxref{File Search Services, +@code{package-database-service-type}}). The general syntax is: @@ -24986,6 +24988,51 @@ File Search Services @end table @end deftp +The second service, @code{package-database-service-type}, builds the +database used by @command{guix locate}, which lets you search for +packages that contain a given file (@pxref{Invoking guix locate}). The +service periodically updates a system-wide database, which will be +readily available to anyone running @command{guix locate} on the system. +To use this service with its default settings, add this snippet to your +service list: + +@lisp +(service package-database-service-type) +@end lisp + +This will run @command{guix locate --update} once a week. + +@defvar package-database-service-type +This is the service type for periodic @command{guix locate} updates +(@pxref{Invoking guix locate}). Its value must be a +@code{package-database-configuration} record, as shown below. +@end defvar + +@deftp {Data Type} package-database-configuration +Data type to configure periodic package database updates. It has the +following fields: + +@table @asis +@item @code{package} (default: @code{guix}) +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}). + +@item @code{method} (default: @code{'store}) +Indexing method for @command{guix locate}. The default value, +@code{'store}, yields a more complete database but is relatively +expensive in terms of CPU and input/output. + +@item @code{channels} (default: @code{#~%default-channels}) +G-exp denoting the channels to use when updating the database +(@pxref{Channels}). +@end table +@end deftp + + @node Database Services @subsection Database Services diff --git a/gnu/services/admin.scm b/gnu/services/admin.scm index 57fdfc35c0..f16880029f 100644 --- a/gnu/services/admin.scm +++ b/gnu/services/admin.scm @@ -28,6 +28,8 @@ (define-module (gnu services admin) #:use-module (gnu services) #:use-module (gnu services mcron) #:use-module (gnu services shepherd) + #:use-module (gnu system accounts) + #:use-module ((gnu system shadow) #:select (account-service-type)) #:use-module ((guix store) #:select (%store-prefix)) #:use-module (guix gexp) #:use-module (guix modules) @@ -67,6 +69,14 @@ (define-module (gnu services admin) %default-file-database-update-schedule %default-file-database-excluded-directories + package-database-service-type + package-database-configuration + package-database-configuration? + package-database-configuration-package + package-database-configuration-schedule + package-database-configuration-method + package-database-configuration-channels + unattended-upgrade-service-type unattended-upgrade-configuration unattended-upgrade-configuration? @@ -322,6 +332,45 @@ (define file-database-service-type the @command{updatedb} command.") (default-value (file-database-configuration)))) +(define %default-package-database-update-schedule + ;; Default mcron schedule for the periodic 'guix locate --update' job: once + ;; every Monday. + "10 23 * * 1") + +(define-record-type* + package-database-configuration make-package-database-configuration + package-database-configuration? + (package package-database-configuration-package + (default guix)) + (schedule package-database-configuration-schedule + (default %default-package-database-update-schedule)) + (method package-database-configuration-method + (default 'store)) + (channels package-database-configuration-channels + (default #~%default-channels))) + +(define (package-database-mcron-jobs 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))))))) + +(define package-database-service-type + (service-type + (name 'package-database) + (extensions (list (service-extension mcron-service-type + package-database-mcron-jobs))) + (description + "Periodically update the package database used by the @code{guix locate} command, +which lets you search for packages that provide a given file.") + (default-value (package-database-configuration)))) + ;;; ;;; Unattended upgrade. -- 2.40.1 From debbugs-submit-bounces@debbugs.gnu.org Thu Jul 13 14:00:58 2023 Received: (at 64471) by debbugs.gnu.org; 13 Jul 2023 18:00:58 +0000 Received: from localhost ([127.0.0.1]:40820 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qK0cc-0001nx-7e for submit@debbugs.gnu.org; Thu, 13 Jul 2023 14:00:58 -0400 Received: from smtpmciv4.myservices.hosting ([185.26.107.240]:54012) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qK0cX-0001nl-ES for 64471@debbugs.gnu.org; Thu, 13 Jul 2023 14:00:56 -0400 Received: from mail1.netim.hosting (unknown [185.26.106.173]) by smtpmciv4.myservices.hosting (Postfix) with ESMTP id BA22F20781; Thu, 13 Jul 2023 20:00:51 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by mail1.netim.hosting (Postfix) with ESMTP id 0E1138009B; Thu, 13 Jul 2023 20:00:51 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at mail1.netim.hosting Received: from mail1.netim.hosting ([127.0.0.1]) by localhost (mail1-2.netim.hosting [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id 7iqC9KcD8hrF; Thu, 13 Jul 2023 20:00:50 +0200 (CEST) Received: from [192.168.1.116] (unknown [10.192.1.83]) (Authenticated sender: lumen@makinata.eu) by mail1.netim.hosting (Postfix) with ESMTPSA id 9B4CB80099; Thu, 13 Jul 2023 20:00:50 +0200 (CEST) Message-ID: Date: Thu, 13 Jul 2023 19:00:46 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.12.0 Subject: Re: [bug#64471] [PATCH 1/2] services: Add 'file-database' service. Content-Language: en-US To: =?UTF-8?Q?Ludovic_Court=c3=a8s?= References: From: Bruno Victal In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Score: -0.1 (/) X-Debbugs-Envelope-To: 64471 Cc: 64471@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.1 (-) Hi Ludo’, On 2023-07-05 11:16, Ludovic Courtès wrote: > +(define-record-type* > + file-database-configuration make-file-database-configuration > + file-database-configuration? > + (package file-database-configuration-package > + (default > + (let-system (system target) > + ;; Unless we're cross-compiling, avoid pulling a > + ;; second copy of findutils. > + (if target > + findutils > + (canonical-package findutils))))) > + (schedule file-database-configuration-schedule > + (default %default-file-database-update-schedule)) > + (excluded-directories file-database-configuration-excluded-directories > + (default %default-file-database-excluded-directories))) How about using define-configuration instead to have the documentation neatly in sync with the fields? > + > +(define (file-database-mcron-jobs configuration) > + (match-record configuration > + (package schedule excluded-directories) > + (let ((updatedb (program-file > + "updatedb" > + #~(execl #$(file-append package "/bin/updatedb") > + "updatedb" > + #$(string-append "--prunepaths=" > + (string-join > + excluded-directories)))))) > + (list #~(job #$schedule #$updatedb))))) I'm afraid #$schedule might be insufficient if this is a _mcron_ time-spec. There's an elaborate dance done by fstrim-service-type to handle the more exotic mcron time expressions, perhaps you can reuse it here? -- Furthermore, I consider that nonfree software must be eradicated. Cheers, Bruno. From debbugs-submit-bounces@debbugs.gnu.org Mon Jul 17 16:22:24 2023 Received: (at 64471) by debbugs.gnu.org; 17 Jul 2023 20:22:24 +0000 Received: from localhost ([127.0.0.1]:50994 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qLUjg-0007vv-8p for submit@debbugs.gnu.org; Mon, 17 Jul 2023 16:22:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54186) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qLUje-0007vi-4x for 64471@debbugs.gnu.org; Mon, 17 Jul 2023 16:22:23 -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 1qLUjY-0000lO-Ux; Mon, 17 Jul 2023 16:22:16 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:In-Reply-To:Date:References:Subject:To: From; bh=eJGLbrkkwASLealseZFrWqZt2RG8z2lXqAvOibKdPiE=; b=fCl9atmYGzHZ2/pZ9GbH XBj7w7bnh2IrqPQcKNZLf1jzP+4yP2qHEVKviKiXfpI5caFdFLRcALZJxE6o8OMmLGRC0kFIwHMzJ wXN3iLX4msKpBtbkBMU2CKKmrpwU1VG9wH/DSPphQWjPtAlLftPwyqHNXyAX+rLCNMdkQ1pOStMKV SdR5AT5RaV78mmRVhB/fp5al6Orb5bD3r6bIoaOj0pB0jurlfPgzIzHew+PHdQP17tVub7QUWQ5Ix jaZw5w6j6uzJNHwASShE6J8fPVmQP3BenhU6MqW17nY8rLZO7CLJ/KFM/ZP6LfZwPP55y8cSmZy/z ofAyX8cRuxxeyg==; Received: from 91-160-117-201.subs.proxad.net ([91.160.117.201] helo=ribbon) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qLUjY-00059j-IT; Mon, 17 Jul 2023 16:22:16 -0400 From: =?utf-8?Q?Ludovic_Court=C3=A8s?= To: Bruno Victal Subject: Re: bug#64471: [PATCH 0/2] File database update services References: Date: Mon, 17 Jul 2023 22:22:14 +0200 In-Reply-To: (Bruno Victal's message of "Thu, 13 Jul 2023 19:00:46 +0100") Message-ID: <87o7kanv9l.fsf_-_@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 64471 Cc: 64471@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Hello, Bruno Victal skribis: > On 2023-07-05 11:16, Ludovic Court=C3=A8s wrote: >> +(define-record-type* >> + file-database-configuration make-file-database-configuration >> + file-database-configuration? >> + (package file-database-configuration-package >> + (default >> + (let-system (system target) >> + ;; Unless we're cross-compiling, avoid pull= ing a >> + ;; second copy of findutils. >> + (if target >> + findutils >> + (canonical-package findutils))))) >> + (schedule file-database-configuration-schedule >> + (default %default-file-database-update-schedule= )) >> + (excluded-directories file-database-configuration-excluded-directories >> + (default %default-file-database-excluded-direct= ories))) > > How about using define-configuration instead to have the documentation ne= atly > in sync with the fields? Hmm, good point, I=E2=80=99ll take a look. >> +(define (file-database-mcron-jobs configuration) >> + (match-record configuration >> + (package schedule excluded-directories) >> + (let ((updatedb (program-file >> + "updatedb" >> + #~(execl #$(file-append package "/bin/updatedb") >> + "updatedb" >> + #$(string-append "--prunepaths=3D" >> + (string-join >> + excluded-directories)))= ))) >> + (list #~(job #$schedule #$updatedb))))) > > I'm afraid #$schedule might be insufficient if this is a _mcron_ time-spe= c. > There's an elaborate dance done by fstrim-service-type to handle the more= exotic > mcron time expressions, perhaps you can reuse it here? I=E2=80=99m not sure what fstrim-service-type is trying to achieve with thi= s: #~(job ;; Note: The =E2=80=9Cif=E2=80=9D 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) =E2=80=A6") If we simply have: #~(job #$schedule =E2=80=A6) then =E2=80=98schedule=E2=80=99 can be anything you might expect, like: =E2=80=A2 "0 * * * *" ;string =E2=80=A2 #~(next-hour =E2=80=A6) ;gexp =E2=80=A2 #~(lambda (x) =E2=80=A6) ;another gexp What=E2=80=99s the problem? :-) Ludo=E2=80=99. From debbugs-submit-bounces@debbugs.gnu.org Thu Jul 20 17:23:02 2023 Received: (at 64471) by debbugs.gnu.org; 20 Jul 2023 21:23:02 +0000 Received: from localhost ([127.0.0.1]:60108 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qMb6z-0001hH-7E for submit@debbugs.gnu.org; Thu, 20 Jul 2023 17:23:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46436) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qMb6u-0001gu-Tt for 64471@debbugs.gnu.org; Thu, 20 Jul 2023 17:23:00 -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 1qMb6o-0002FU-CD; Thu, 20 Jul 2023 17:22:50 -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=JbiY8AXqsmk9Yt/5HGY5XTwxIDGzMJDKSPHRBnp44vA=; b=bEkC+KQuAhzmm/m54NOb de3J5WiDqu9G2v7aZJ0i5ick36kU9PIxvzEgL5Dcs0SboqAdRdvjlUBhMkxZaeBIYEMNa6XR+rTz8 IO+pALbjH37LK3vojNRPdTD2aNHgie/uj39st7lQ6N7q2rTSORrIBz8aWNlLO4seIGGYH6X5GDo6N M1r6tB+vDOdPCLzjx5d5BvxjPxjf0YepLbA4XPBdrJZc5Pz2WqeF8mnsFElXhWhZDo+/41uwR1z7m aJBM8qASRpmTAHP/oPtJdYVk270MecHJdzUWBtKuqsn97Vc0Z3SIhvLFoKQEQiCY1JP3J3kDXHiOU RR5X/oj8ki0tKw==; Received: from [78.199.208.147] (helo=gnu.org) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qMb6o-0006EZ-03; Thu, 20 Jul 2023 17:22:50 -0400 From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= To: 64471@debbugs.gnu.org Subject: [PATCH v2 1/2] services: Add 'file-database' service. Date: Thu, 20 Jul 2023 23:22:27 +0200 Message-ID: X-Mailer: git-send-email 2.41.0 In-Reply-To: <87o7kanv9l.fsf_-_@gnu.org> References: <87o7kanv9l.fsf_-_@gnu.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 64471 Cc: =?UTF-8?q?Ludovic=20Court=C3=A8s?= , Bruno Victal X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) * gnu/services/admin.scm (%default-file-database-update-schedule) (%default-file-database-excluded-directories): New variables. (): New record type. (file-database-mcron-jobs): New procedure. (file-database-service-type): New variable. * doc/guix.texi (File Search Services): New node. --- doc/guix.texi | 62 +++++++++++++++++++++++++++++++ gnu/services/admin.scm | 83 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 145 insertions(+) Change since v1: use of 'define-configuration' instead of 'define-record-type*'. However, I am not using the generated documentation due to . (Overall I'm not fully satisfied with 'define-configuration'.) Thoughts? Ludo'. diff --git a/doc/guix.texi b/doc/guix.texi index 1d8ebcd72f..1d5f7c6b47 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -388,6 +388,7 @@ Top * Printing Services:: Local and remote printer support. * Desktop Services:: D-Bus and desktop services. * Sound Services:: ALSA and Pulseaudio services. +* File Search Services:: Tools to search for files. * Database Services:: SQL databases, key-value stores, etc. * Mail Services:: IMAP, POP3, SMTP, and all that. * Messaging Services:: Messaging services. @@ -18428,6 +18429,7 @@ Services * Printing Services:: Local and remote printer support. * Desktop Services:: D-Bus and desktop services. * Sound Services:: ALSA and Pulseaudio services. +* File Search Services:: Tools to search for files. * Database Services:: SQL databases, key-value stores, etc. * Mail Services:: IMAP, POP3, SMTP, and all that. * Messaging Services:: Messaging services. @@ -24938,6 +24940,66 @@ Sound Services @end defvar +@node File Search Services +@subsection File Search Services + +@cindex file search +@cindex searching for a file +The services in this section populate @dfn{file databases} that let you +search for files on your machine. These services are provided by the +@code{(gnu services admin)} module. + +The first one, @code{file-database-service-type}, periodically runs the +venerable @command{updatedb} command (@pxref{Invoking updatedb,,, find, +GNU Findutils}). That command populates a database of file names that +you can then search with the @command{locate} command (@pxref{Invoing +locate,,, find, GNU Findutils}), as in this example: + +@example +locate important-notes.txt +@end example + +You can enable this service with its default settings by adding this +snippet to your operating system services: + +@lisp +(service file-database-service-type) +@end lisp + +This updates the database once a week, excluding files from +@file{/gnu/store}---these are more usefully handled by @command{guix +locate} (@pxref{Invoking guix locate}). You can of course provide a +custom configuration, as described below. + +@defvar file-database-service-type +This is the type of the file database service, which runs +@command{updatedb} periodically. Its associated value must be a +@code{file-database-configuration} record, as described below. +@end defvar + +@deftp {Data Type} file-database-configuration +Record type for the @code{file-database-service-type} configuration, +with the following fields: + +@table @asis +@item @code{package} (default: @code{findutils}) +The GNU@tie{}Findutils package from which the @command{updatedb} command +is taken. + +@item @code{schedule} (default: @code{%default-file-database-update-schedule}) +String or G-exp denoting an mcron schedule for the periodic +@command{updatedb} job (@pxref{Guile Syntax,,, mcron, GNU@tie{}mcron}). + +@item @code{excluded-directories} (default @code{%default-file-database-excluded-directories}) +List of directories to ignore when building the file database. By +default, this includes @file{/tmp} and @file{/gnu/store}, which should +instead be indexed by @command{guix locate} (@pxref{Invoking guix +locate}). This list is passed to the @option{--prunepaths} option of +@command{updatedb} (@pxref{Invoking updatedb,,, find, +GNU@tie{}Findutils}). +@end table +@end deftp + @node Database Services @subsection Database Services diff --git a/gnu/services/admin.scm b/gnu/services/admin.scm index 1c10cfb1f6..636367a6f3 100644 --- a/gnu/services/admin.scm +++ b/gnu/services/admin.scm @@ -21,16 +21,21 @@ (define-module (gnu services admin) #:use-module (gnu packages admin) + #:use-module ((gnu packages base) + #:select (canonical-package findutils)) #:use-module (gnu packages certs) #:use-module (gnu packages package-management) #:use-module (gnu services) + #:use-module (gnu services configuration) #:use-module (gnu services mcron) #:use-module (gnu services shepherd) + #:use-module ((guix store) #:select (%store-prefix)) #:use-module (guix gexp) #:use-module (guix modules) #:use-module (guix packages) #:use-module (guix records) #:use-module (srfi srfi-1) + #:use-module (ice-9 match) #:use-module (ice-9 vlist) #:export (%default-rotations %rotated-files @@ -55,6 +60,15 @@ (define-module (gnu services admin) log-cleanup-configuration-expiry log-cleanup-configuration-schedule + file-database-service-type + file-database-configuration + file-database-configuration? + file-database-configuration-package + file-database-configuration-schedule + file-database-configuration-excluded-directories + %default-file-database-update-schedule + %default-file-database-excluded-directories + unattended-upgrade-service-type unattended-upgrade-configuration unattended-upgrade-configuration? @@ -255,6 +269,75 @@ (define log-cleanup-service-type (description "Periodically delete old log files."))) + +;;; +;;; File databases. +;;; + +(define %default-file-database-update-schedule + ;; Default mcron schedule for the periodic 'updatedb' job: once every + ;; Sunday. + "10 23 * * 0") + +(define %default-file-database-excluded-directories + ;; Directories excluded from the 'locate' database. + (list (%store-prefix) + "/tmp" "/var/tmp" "/var/cache" ".*/\\.cache" + "/run/udev")) + +(define (string-or-gexp? obj) + (or (string? obj) (gexp? obj))) + +(define string-list? + (match-lambda + (((? string) ...) #t) + (_ #f))) + +(define-configuration/no-serialization file-database-configuration + (package + (file-like (let-system (system target) + ;; Unless we're cross-compiling, avoid pulling a second copy + ;; of findutils. + (if target + findutils + (canonical-package findutils)))) + "The GNU@tie{}Findutils package from which the @command{updatedb} command +is taken.") + (schedule + (string-or-gexp %default-file-database-update-schedule) + "String or G-exp denoting an mcron schedule for the periodic +@command{updatedb} job (@pxref{Guile Syntax,,, mcron, GNU@tie{}mcron}).") + (excluded-directories + (string-list %default-file-database-excluded-directories) + "List of directories to ignore when building the file database. By +default, this includes @file{/tmp} and @file{/gnu/store}, which should instead +be indexed by @command{guix locate} (@pxref{Invoking guix locate}). This list +is passed to the @option{--prunepaths} option of +@command{updatedb} (@pxref{Invoking updatedb,,, find, GNU@tie{}Findutils}).")) + +(define (file-database-mcron-jobs configuration) + (match-record configuration + (package schedule excluded-directories) + (let ((updatedb (program-file + "updatedb" + #~(execl #$(file-append package "/bin/updatedb") + "updatedb" + #$(string-append "--prunepaths=" + (string-join + excluded-directories)))))) + (list #~(job #$schedule #$updatedb))))) + +(define file-database-service-type + (service-type + (name 'file-database) + (extensions (list (service-extension mcron-service-type + file-database-mcron-jobs))) + (description + "Periodically update the file database used by the @command{locate} command, +which lets you search for files by name. The database is created by running +the @command{updatedb} command.") + (default-value (file-database-configuration)))) + ;;; ;;; Unattended upgrade. base-commit: 283969d0c527aa41e65bb4f5c2a7fa3baf86c49a -- 2.41.0 From debbugs-submit-bounces@debbugs.gnu.org Thu Jul 20 17:23:07 2023 Received: (at 64471) by debbugs.gnu.org; 20 Jul 2023 21:23:07 +0000 Received: from localhost ([127.0.0.1]:60113 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qMb75-0001iJ-1p for submit@debbugs.gnu.org; Thu, 20 Jul 2023 17:23:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46452) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qMb6y-0001gz-0P for 64471@debbugs.gnu.org; Thu, 20 Jul 2023 17:23:00 -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 1qMb6s-0002GP-Px; Thu, 20 Jul 2023 17:22:54 -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=NDSYC1/E8nnKRUHF89vIlymo+sKyDP42Fmv8d6aZmi0=; b=jtPgk0KcSzcIegkrOmdc esDNljy+xdQUE5jn3YEt48k9bdwvqsyqsWJwLOY+u1RTq/EJlU19aKyMUgGMtemXA325rgl6WsMfP CCd9ShRssobRANQ/Elcc+NiQuNqUounj2iObTLgRHtkpx6UHVImkQNYNwEDVG8x5MoN8Z/Nop0Q3h mySxdQx1w2vzjelpgZiMj3qC8OS2P23ObPGX8+127iVEVfj4Wh6dSg10+TT9PouA8hxvcCVR/khQg 42Iy9Y4aNWk1dGHT3rDuk5NT7q4ZeqBkwHcNV9csJjSpkK6BJZ+IpPeGEf47X1ULHtasf//iM0aTe AuISWsR8kSClrw==; Received: from [78.199.208.147] (helo=gnu.org) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qMb6r-0006EZ-4x; Thu, 20 Jul 2023 17:22:54 -0400 From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= To: 64471@debbugs.gnu.org Subject: [PATCH v2 2/2] services: Add 'package-database' service. Date: Thu, 20 Jul 2023 23:22:28 +0200 Message-ID: <53bce8c28952116dc795d25f7c47e9360d0c9986.1689888002.git.ludo@gnu.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <87o7kanv9l.fsf_-_@gnu.org> References: <87o7kanv9l.fsf_-_@gnu.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 64471 Cc: =?UTF-8?q?Ludovic=20Court=C3=A8s?= , Bruno Victal X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) * gnu/services/admin.scm (%default-package-database-update-schedule): New variable. (): New record type. (package-database-mcron-jobs): New procedure. (package-database-service-type): New variable. * doc/guix.texi (File Search Services): Document it. --- doc/guix.texi | 49 +++++++++++++++++++++++++++++++++++++- gnu/services/admin.scm | 53 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 101 insertions(+), 1 deletion(-) diff --git a/doc/guix.texi b/doc/guix.texi index 1d5f7c6b47..833865f009 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -4481,7 +4481,9 @@ Invoking guix locate exist or is too old, it falls back to the per-user database, by default under @file{~/.cache/guix/locate}. On a multi-user system, administrators may want to periodically update the system-wide database -so that all users can benefit from it. +so that all users can benefit from it, for instance by setting up +@code{package-database-service-type} (@pxref{File Search Services, +@code{package-database-service-type}}). The general syntax is: @@ -25000,6 +25002,51 @@ File Search Services @end table @end deftp +The second service, @code{package-database-service-type}, builds the +database used by @command{guix locate}, which lets you search for +packages that contain a given file (@pxref{Invoking guix locate}). The +service periodically updates a system-wide database, which will be +readily available to anyone running @command{guix locate} on the system. +To use this service with its default settings, add this snippet to your +service list: + +@lisp +(service package-database-service-type) +@end lisp + +This will run @command{guix locate --update} once a week. + +@defvar package-database-service-type +This is the service type for periodic @command{guix locate} updates +(@pxref{Invoking guix locate}). Its value must be a +@code{package-database-configuration} record, as shown below. +@end defvar + +@deftp {Data Type} package-database-configuration +Data type to configure periodic package database updates. It has the +following fields: + +@table @asis +@item @code{package} (default: @code{guix}) +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}). + +@item @code{method} (default: @code{'store}) +Indexing method for @command{guix locate}. The default value, +@code{'store}, yields a more complete database but is relatively +expensive in terms of CPU and input/output. + +@item @code{channels} (default: @code{#~%default-channels}) +G-exp denoting the channels to use when updating the database +(@pxref{Channels}). +@end table +@end deftp + + @node Database Services @subsection Database Services diff --git a/gnu/services/admin.scm b/gnu/services/admin.scm index 636367a6f3..0c24cedd43 100644 --- a/gnu/services/admin.scm +++ b/gnu/services/admin.scm @@ -29,6 +29,8 @@ (define-module (gnu services admin) #:use-module (gnu services configuration) #:use-module (gnu services mcron) #:use-module (gnu services shepherd) + #:use-module (gnu system accounts) + #:use-module ((gnu system shadow) #:select (account-service-type)) #:use-module ((guix store) #:select (%store-prefix)) #:use-module (guix gexp) #:use-module (guix modules) @@ -69,6 +71,14 @@ (define-module (gnu services admin) %default-file-database-update-schedule %default-file-database-excluded-directories + package-database-service-type + package-database-configuration + package-database-configuration? + package-database-configuration-package + package-database-configuration-schedule + package-database-configuration-method + package-database-configuration-channels + unattended-upgrade-service-type unattended-upgrade-configuration unattended-upgrade-configuration? @@ -338,6 +348,49 @@ (define file-database-service-type the @command{updatedb} command.") (default-value (file-database-configuration)))) +(define %default-package-database-update-schedule + ;; Default mcron schedule for the periodic 'guix locate --update' job: once + ;; every Monday. + "10 23 * * 1") + +(define-configuration/no-serialization package-database-configuration + (package (file-like guix) + "The Guix package to use.") + (schedule (string-or-gexp + %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}).") + (method (symbol 'store) + "Indexing method for @command{guix locate}. The default value, +@code{'store}, yields a more complete database but is relatively expensive in +terms of CPU and input/output.") + (channels (gexp #~%default-channels) + "G-exp denoting the channels to use when updating the database +(@pxref{Channels}).")) + +(define (package-database-mcron-jobs 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))))))) + +(define package-database-service-type + (service-type + (name 'package-database) + (extensions (list (service-extension mcron-service-type + package-database-mcron-jobs))) + (description + "Periodically update the package database used by the @code{guix locate} command, +which lets you search for packages that provide a given file.") + (default-value (package-database-configuration)))) + ;;; ;;; Unattended upgrade. -- 2.41.0 From debbugs-submit-bounces@debbugs.gnu.org Wed Jul 26 09:22:37 2023 Received: (at 64471) by debbugs.gnu.org; 26 Jul 2023 13:22:37 +0000 Received: from localhost ([127.0.0.1]:47717 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qOeTN-0007vs-AU for submit@debbugs.gnu.org; Wed, 26 Jul 2023 09:22:37 -0400 Received: from smtpm5.myservices.hosting ([185.26.105.236]:60712) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qOeTK-0007vf-Lo for 64471@debbugs.gnu.org; Wed, 26 Jul 2023 09:22:35 -0400 Received: from mail1.netim.hosting (unknown [185.26.106.173]) by smtpm5.myservices.hosting (Postfix) with ESMTP id 5877820CBA; Wed, 26 Jul 2023 15:22:33 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by mail1.netim.hosting (Postfix) with ESMTP id 99FA7800AC; Wed, 26 Jul 2023 15:22:32 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at mail1.netim.hosting Received: from mail1.netim.hosting ([127.0.0.1]) by localhost (mail1-2.netim.hosting [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id nhag5cCDTz2A; Wed, 26 Jul 2023 15:22:32 +0200 (CEST) Received: from [192.168.1.116] (unknown [10.192.1.83]) (Authenticated sender: lumen@makinata.eu) by mail1.netim.hosting (Postfix) with ESMTPSA id EAD2A800A9; Wed, 26 Jul 2023 15:22:31 +0200 (CEST) Message-ID: Date: Wed, 26 Jul 2023 14:22:27 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 Subject: Re: bug#64471: [PATCH 0/2] File database update services Content-Language: en-US To: =?UTF-8?Q?Ludovic_Court=c3=a8s?= References: <87o7kanv9l.fsf_-_@gnu.org> From: Bruno Victal In-Reply-To: <87o7kanv9l.fsf_-_@gnu.org> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Score: -0.1 (/) X-Debbugs-Envelope-To: 64471 Cc: 64471@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.1 (-) Hi Ludo’, On 2023-07-17 21:22, Ludovic Courtès wrote: > Bruno Victal skribis: > >> >> I'm afraid #$schedule might be insufficient if this is a _mcron_ time-spec. >> There's an elaborate dance done by fstrim-service-type to handle the more exotic >> mcron time expressions, perhaps you can reuse it here? > > I’m not sure what fstrim-service-type is trying to achieve with this: > > #~(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) > …") > > If we simply have: > > #~(job #$schedule …) > > then ‘schedule’ can be anything you might expect, like: > > • "0 * * * *" ;string > > • #~(next-hour …) ;gexp > > • #~(lambda (x) …) ;another gexp > > What’s the problem? :-) There's a third choice for that argument: a staged expression/list, hence the gexp/ungexp dance. [1]: [2]: -- Furthermore, I consider that nonfree software must be eradicated. Cheers, Bruno. From debbugs-submit-bounces@debbugs.gnu.org Wed Jul 26 09:28:46 2023 Received: (at 64471) by debbugs.gnu.org; 26 Jul 2023 13:28:46 +0000 Received: from localhost ([127.0.0.1]:47726 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qOeZK-00087A-2B for submit@debbugs.gnu.org; Wed, 26 Jul 2023 09:28:46 -0400 Received: from smtpm3.myservices.hosting ([185.26.105.234]:34404) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qOeZG-00086x-JY for 64471@debbugs.gnu.org; Wed, 26 Jul 2023 09:28:44 -0400 Received: from mail1.netim.hosting (unknown [185.26.106.173]) by smtpm3.myservices.hosting (Postfix) with ESMTP id 96DA420DD4; Wed, 26 Jul 2023 15:28:41 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by mail1.netim.hosting (Postfix) with ESMTP id E63BF8009D; Wed, 26 Jul 2023 15:28:40 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at mail1.netim.hosting Received: from mail1.netim.hosting ([127.0.0.1]) by localhost (mail1-2.netim.hosting [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id T1XZL6kM76Cy; Wed, 26 Jul 2023 15:28:40 +0200 (CEST) Received: from [192.168.1.116] (unknown [10.192.1.83]) (Authenticated sender: lumen@makinata.eu) by mail1.netim.hosting (Postfix) with ESMTPSA id 8BF2A80060; Wed, 26 Jul 2023 15:28:40 +0200 (CEST) Message-ID: <9e3682c7-aa0c-3f96-3c14-5f5a2291dcc9@makinata.eu> Date: Wed, 26 Jul 2023 14:28:40 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 Subject: Re: [PATCH v2 1/2] services: Add 'file-database' service. Content-Language: en-US To: =?UTF-8?Q?Ludovic_Court=c3=a8s?= References: <87o7kanv9l.fsf_-_@gnu.org> From: Bruno Victal In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Score: -0.1 (/) X-Debbugs-Envelope-To: 64471 Cc: 64471@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.1 (-) On 2023-07-20 22:22, Ludovic Courtès wrote: > +(define string-list? > + (match-lambda > + (((? string) ...) #t) > + (_ #f))) There's a procedure 'list-of' from (gnu services configuration) that you can use to define these kinds of procedures. In fact, there's already a list-of-strings? predicate as a starting point within said module that you can use instead. -- Furthermore, I consider that nonfree software must be eradicated. Cheers, Bruno. From debbugs-submit-bounces@debbugs.gnu.org Mon Aug 07 10:39:30 2023 Received: (at 64471-done) by debbugs.gnu.org; 7 Aug 2023 14:39:30 +0000 Received: from localhost ([127.0.0.1]:34076 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qT1OM-0005RL-BT for submit@debbugs.gnu.org; Mon, 07 Aug 2023 10:39:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34930) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qT1OJ-0005Qz-A7 for 64471-done@debbugs.gnu.org; Mon, 07 Aug 2023 10:39:28 -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 1qT1OD-0002Ib-0A; Mon, 07 Aug 2023 10:39: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:In-Reply-To:Date:References:Subject:To: From; bh=RN6ZSJllGSg939QLnZEc5mPsHk6f3dDVHa3HjnFflfE=; b=hD91qwHQjI/JUgNgSPP2 x9+zDgsSTXW0fFudbCzfc/1/UOWDkArv8DZ870az1tCFMZVlw4XkTaIgsSQoyexBENRmmNpp/j7rf aG6HLh9WBN8Zc89qAx6yptFLwGQxwILhA4DUB0Me6EKWuDpi8HM0EJy2Ik6pOU7/X0nEzFEAlQ4T6 0lwV1Sy75rrAaLVGsmanaNupnGlg7/DpxpyQGF0/RhHE4tRyIb5gKj59G7iPdV0VAqxaFfYGSdxmR Iqbm0JSElBx7nv7vzfdrnfd8+bA671FcGvPMBETmPfcvcpyNIpWcxWWFi1NR9lqieGcLTQez5rU6e a7vwPjn6WGsXdQ==; From: =?utf-8?Q?Ludovic_Court=C3=A8s?= To: 64471-done@debbugs.gnu.org Subject: Re: bug#64471: [PATCH 0/2] File database update services References: Date: Mon, 07 Aug 2023 16:39:18 +0200 In-Reply-To: ("Ludovic =?utf-8?Q?Court?= =?utf-8?Q?=C3=A8s=22's?= message of "Wed, 5 Jul 2023 11:59:44 +0200") Message-ID: <87pm3ysyqx.fsf@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 64471-done Cc: Bruno Victal X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Ludovic Court=C3=A8s skribis: > services: Add 'file-database' service. > services: Add 'package-database' service. Pushed as b3a2b3e7238161ebd86c7609f68e8f1e9c1dd6b7! Ludo=E2=80=99. From unknown Mon Aug 18 04:43:34 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Tue, 05 Sep 2023 11:24:10 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator