home-services: Add fold-home-service-types function.

* gnu/home-services.scm (parent-directory, %guix-home-root-directory,
%service-type-path, all-home-service-modules, fold-home-service-types): New
variables.

Signed-off-by: Oleg Pykhalov <go.wigust@gmail.com>
This commit is contained in:
Andrew Tropin 2021-08-05 08:47:40 +03:00 committed by Oleg Pykhalov
parent 305edf9c3a
commit 05093ffda2
No known key found for this signature in database
GPG key ID: 167F8EA5001AFA9C

View file

@ -492,3 +492,29 @@ (define home-provenance-service-type
(define sexp->home-provenance sexp->system-provenance)
(define home-provenance system-provenance)
;;;
;;; Searching
;;;
(define (parent-directory directory)
"Get the parent directory of DIRECTORY"
(string-join (drop-right (string-split directory #\/) 1) "/"))
(define %guix-home-root-directory
;; Absolute file name of the module hierarchy.
(parent-directory (dirname (search-path %load-path "gnu/home-services.scm"))))
(define %service-type-path
;; Search path for service types.
(make-parameter `((,%guix-home-root-directory . "gnu/home-services"))))
(define (all-home-service-modules)
"Return the default set of home-service modules."
(cons (resolve-interface '(gnu home-services))
(all-modules (%service-type-path)
#:warn warn-about-load-error)))
(define* (fold-home-service-types proc seed)
(fold-service-types proc seed (all-home-service-modules)))