From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp12.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms9.migadu.com with LMTPS id 2EcyDTdDpWQSUwAASxT56A (envelope-from ) for ; Wed, 05 Jul 2023 12:17:27 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp12.migadu.com with LMTPS id cAEJDTdDpWSuXAEAauVa8A (envelope-from ) for ; Wed, 05 Jul 2023 12:17:27 +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 D2A8B105D4 for ; Wed, 5 Jul 2023 12:17:26 +0200 (CEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qGzZL-0006OL-KI; Wed, 05 Jul 2023 06:17:07 -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 1qGzZH-0006O4-Cb for guix-patches@gnu.org; Wed, 05 Jul 2023 06:17:03 -0400 Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qGzZH-0007ao-21 for guix-patches@gnu.org; Wed, 05 Jul 2023 06:17:03 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qGzZG-0006hf-FC for guix-patches@gnu.org; Wed, 05 Jul 2023 06:17:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#64471] [PATCH 1/2] services: Add 'file-database' service. Resent-From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Wed, 05 Jul 2023 10:17:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 64471 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 64471@debbugs.gnu.org Cc: Ludovic =?UTF-8?Q?Court=C3=A8s?= Received: via spool by 64471-submit@debbugs.gnu.org id=B64471.168855222125758 (code B ref 64471); Wed, 05 Jul 2023 10:17:02 +0000 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: Ludovic =?UTF-8?Q?Court=C3=A8s?= 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-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-Country: US X-Migadu-Flow: FLOW_IN ARC-Seal: i=1; s=key1; d=yhetil.org; t=1688552247; a=rsa-sha256; cv=none; b=fvhf6xUNP33JxXb2YSBeMRjKhgylFFgqJSO2+ahCXdbAAijDlinvFKlpMiivJIJ7WeoRyE NneNszsQQdcrUNPr61RUttSw7hP+tl/YvppyDLR1+fAJdRGgK/h2qPN8gmOlfksd+gC7ei w433r9NxZlkru/2Dvp9XfcnJ2+Za+vNg9uVhzIFX776WvnnqmkLV34rvVhFFyhiLqXnNBS ttJsg1rRd9Y8p4KwgyEdHYzkTqIi4CuTFgLovjVNFw7HYOhWPeP6d+AG6ij+GFelXHOzL5 gvuQq7Lf2qR5dRCDVCFCr4kder+2dcGkjwT+HBnw6JM0OBHLx51g83Z/ULkpdw== 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=k6Ecejhg; dmarc=pass (policy=none) header.from=gnu.org; 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" ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1688552247; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: 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=UioodNawaAyUAunHpuS1WamFJ6L/z8rDqKrZHwm+uts=; b=Yl7r91ijNeDMqM+PneBPONi6BXSLolLQVOvgiZol0srOckVnMlqRyVAAbdjKDXZeUi/538 8v3lJZ2s/zeeFehnomZBN92uSOxsszGY0kUTQGytXvY50y6Lj5F7Z55dUCA2kQn1mRHv4E oDA9qx1iUwMB2M+xfcf0dZyOWJD8cPZtPUyskrF2jcLxM8hIas+xnLsyk8asGMz8ghhn0M hIVJhsIZ+GylRIHUmTeWuQsour8c7BW4AEuuX3LBWtzl09k3qRIxpV2My5c+k6am+ij3hW bOY0Y9ajKdP8uuz31olV5TzdQ2fNIa8p8rQsbIHv7QyZlX2IoQUkVZdQ6W3KSw== Authentication-Results: aspmx1.migadu.com; dkim=fail ("body hash did not verify") header.d=gnu.org header.s=fencepost-gnu-org header.b=k6Ecejhg; dmarc=pass (policy=none) header.from=gnu.org; 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" X-Migadu-Scanner: scn0.migadu.com X-Migadu-Spam-Score: -3.16 X-Spam-Score: -3.16 X-Migadu-Queue-Id: D2A8B105D4 X-TUID: I/ISGCSLdBNo * 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