services: Add 'fold-service-types'.
* gnu/services.scm (%distro-root-directory, %service-type-path): New variables. (fold-service-types): New procedure.
This commit is contained in:
parent
b714395a39
commit
0c0c1b21d9
|
@ -23,6 +23,7 @@
|
||||||
#:use-module (guix store)
|
#:use-module (guix store)
|
||||||
#:use-module (guix records)
|
#:use-module (guix records)
|
||||||
#:use-module (guix profiles)
|
#:use-module (guix profiles)
|
||||||
|
#:use-module (guix discovery)
|
||||||
#:use-module (guix sets)
|
#:use-module (guix sets)
|
||||||
#:use-module (guix ui)
|
#:use-module (guix ui)
|
||||||
#:use-module ((guix utils) #:select (source-properties->location))
|
#:use-module ((guix utils) #:select (source-properties->location))
|
||||||
|
@ -52,6 +53,8 @@
|
||||||
service-type-description
|
service-type-description
|
||||||
service-type-location
|
service-type-location
|
||||||
|
|
||||||
|
%service-type-path
|
||||||
|
fold-service-types
|
||||||
|
|
||||||
service
|
service
|
||||||
service?
|
service?
|
||||||
|
@ -165,6 +168,27 @@
|
||||||
|
|
||||||
(set-record-type-printer! <service-type> write-service-type)
|
(set-record-type-printer! <service-type> write-service-type)
|
||||||
|
|
||||||
|
(define %distro-root-directory
|
||||||
|
;; Absolute file name of the module hierarchy.
|
||||||
|
(dirname (search-path %load-path "guix.scm")))
|
||||||
|
|
||||||
|
(define %service-type-path
|
||||||
|
;; Search path for service types.
|
||||||
|
(make-parameter `((,%distro-root-directory . "gnu/services")
|
||||||
|
(,%distro-root-directory . "gnu/system"))))
|
||||||
|
|
||||||
|
(define* (fold-service-types proc seed
|
||||||
|
#:optional
|
||||||
|
(modules (all-modules (%service-type-path))))
|
||||||
|
"For each service type exported by one of MODULES, call (PROC RESULT). SEED
|
||||||
|
is used as the initial value of RESULT."
|
||||||
|
(fold-module-public-variables (lambda (object result)
|
||||||
|
(if (service-type? object)
|
||||||
|
(proc object result)
|
||||||
|
result))
|
||||||
|
'()
|
||||||
|
modules))
|
||||||
|
|
||||||
;; Services of a given type.
|
;; Services of a given type.
|
||||||
(define-record-type <service>
|
(define-record-type <service>
|
||||||
(make-service type value)
|
(make-service type value)
|
||||||
|
|
Loading…
Reference in New Issue