mirror of
https://codeberg.org/guix/guix.git
synced 2025-10-02 02:15:12 +00:00
services: Add 'package-database' service.
* gnu/services/admin.scm (%default-package-database-update-schedule): New variable. (<package-database-configuration>): New record type. (package-database-mcron-jobs): New procedure. (package-database-service-type): New variable. * doc/guix.texi (File Search Services): Document it.
This commit is contained in:
parent
e63c87020d
commit
b3a2b3e723
2 changed files with 101 additions and 1 deletions
|
@ -29,6 +29,8 @@
|
|||
#: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 @@
|
|||
%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 @@ which lets you search for files by name. The database is created by running
|
|||
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-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)))))))
|
||||
|
||||
(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.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue