summaryrefslogtreecommitdiff
path: root/gnu/services/admin.scm
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 /gnu/services/admin.scm
parentf4c832b277846b05c710dc8776c2c0578a03fcd9 (diff)
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
Diffstat (limited to 'gnu/services/admin.scm')
-rw-r--r--gnu/services/admin.scm34
1 files changed, 24 insertions, 10 deletions
diff --git a/gnu/services/admin.scm b/gnu/services/admin.scm
index b73accc4af8..e4737940438 100644
--- a/gnu/services/admin.scm
+++ b/gnu/services/admin.scm
@@ -529,23 +529,37 @@ terms of CPU and input/output.")
529 "G-exp denoting the channels to use when updating the database 529 "G-exp denoting the channels to use when updating the database
530(@pxref{Channels}).")) 530(@pxref{Channels})."))
531 531
532(define (package-database-mcron-jobs configuration) 532(define (package-database-shepherd-services configuration)
533 (match-record configuration <package-database-configuration> 533 (match-record configuration <package-database-configuration>
534 (package schedule method channels) 534 (package schedule method channels)
535 (let ((channels (scheme-file "channels.scm" channels))) 535 (let ((channels (scheme-file "channels.scm" channels)))
536 (list #~(job #$schedule 536 (list (shepherd-service
537 ;; XXX: The whole thing's running as "root" just because it 537 (provision '(package-database-update))
538 ;; needs write access to /var/cache/guix/locate. 538 (requirement '(user-processes guix-daemon))
539 (string-append #$(file-append package "/bin/guix") 539 (modules '((shepherd service timer)))
540 " time-machine -C " #$channels 540 ;; XXX: The whole thing's running as "root" just because it needs
541 " -- locate --update --method=" 541 ;; write access to /var/cache/guix/locate.
542 #$(symbol->string method))))))) 542 (start #~(make-timer-constructor
543 #$(if (string? schedule)
544 #~(cron-string->calendar-event #$schedule)
545 schedule)
546 (command '(#$(file-append package "/bin/guix")
547 "time-machine" "-C" #$channels
548 "--" "locate" "--update"
549 #$(string-append
550 "--method=" (symbol->string method))))
551 #:wait-for-termination? #t))
552 (stop #~(make-timer-destructor))
553 (documentation
554 "Periodically update the system-wide package database that can
555be queried by the 'guix locate' command.")
556 (actions (list shepherd-trigger-action)))))))
543 557
544(define package-database-service-type 558(define package-database-service-type
545 (service-type 559 (service-type
546 (name 'package-database) 560 (name 'package-database)
547 (extensions (list (service-extension mcron-service-type 561 (extensions (list (service-extension shepherd-root-service-type
548 package-database-mcron-jobs))) 562 package-database-shepherd-services)))
549 (description 563 (description
550 "Periodically update the package database used by the @code{guix locate} command, 564 "Periodically update the package database used by the @code{guix locate} command,
551which lets you search for packages that provide a given file.") 565which lets you search for packages that provide a given file.")