aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2025-03-12 16:14:32 +0100
committerLudovic Courtès <ludo@gnu.org>2025-03-23 19:29:41 +0100
commit71ae6f2a191e715c96b02e876f5e40e4932debd8 (patch)
tree366774e4a7ee064ec879ab830ed72b5186328c87
parentf4c832b277846b05c710dc8776c2c0578a03fcd9 (diff)
downloadguix-71ae6f2a191e715c96b02e876f5e40e4932debd8.tar.gz
guix-71ae6f2a191e715c96b02e876f5e40e4932debd8.zip
services: package-database: Turn into a Shepherd timer.
* 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. Reviewed-by: Maxim Cournoyer <maxim.cournoyer@gmail.com> Change-Id: Id7b4c5cff95a7117dca7d95af37db7389bb5ca92
-rw-r--r--doc/guix.texi7
-rw-r--r--gnu/services/admin.scm34
2 files changed, 28 insertions, 13 deletions
diff --git a/doc/guix.texi b/doc/guix.texi
index e6812c1ce3..7538ac99e6 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -27213,9 +27213,10 @@ following fields:
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 @@ terms of CPU and input/output.")
"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-database-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.")