From: "Ludovic Courtès" <ludo@gnu.org>
To: 28452@debbugs.gnu.org
Subject: [bug#28452] [PATCH 3/6] services: Add 'fold-service-types'.
Date: Wed, 13 Sep 2017 23:24:20 +0200 [thread overview]
Message-ID: <20170913212423.5037-3-ludo@gnu.org> (raw)
In-Reply-To: <20170913212423.5037-1-ludo@gnu.org>
* gnu/services.scm (%distro-root-directory, %service-type-path): New
variables.
(fold-service-types): New procedure.
---
gnu/services.scm | 24 ++++++++++++++++++++++++
1 file changed, 24 insertions(+)
diff --git a/gnu/services.scm b/gnu/services.scm
index 83a163b76..2ebd701a5 100644
--- a/gnu/services.scm
+++ b/gnu/services.scm
@@ -23,6 +23,7 @@
#:use-module (guix store)
#:use-module (guix records)
#:use-module (guix profiles)
+ #:use-module (guix discovery)
#:use-module (guix sets)
#:use-module (guix ui)
#:use-module ((guix utils) #:select (source-properties->location))
@@ -52,6 +53,8 @@
service-type-description
service-type-location
+ %service-type-path
+ fold-service-types
service
service?
@@ -165,6 +168,27 @@
(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.
(define-record-type <service>
(make-service type value)
--
2.14.1
next prev parent reply other threads:[~2017-09-13 21:25 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-09-13 21:17 [bug#28452] [PATCH 0/6] On-line doc and search for services Ludovic Courtès
2017-09-13 21:24 ` [bug#28452] [PATCH 1/6] ui: Generalize relevance computation Ludovic Courtès
2017-09-13 21:24 ` [bug#28452] [PATCH 2/6] services: Add a description and location for each service type Ludovic Courtès
2017-09-13 21:24 ` Ludovic Courtès [this message]
2017-09-13 21:24 ` [bug#28452] [PATCH 4/6] guix system: Add 'search' command Ludovic Courtès
2017-09-13 21:24 ` [bug#28452] [PATCH 5/6] services: base: Add descriptions Ludovic Courtès
2017-09-13 21:24 ` [bug#28452] [PATCH 6/6] services: networking: " Ludovic Courtès
2017-09-14 7:37 ` [bug#28452] [PATCH 0/6] On-line doc and search for services Christopher Baines
2017-09-16 16:13 ` bug#28452: " Ludovic Courtès
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://guix.gnu.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170913212423.5037-3-ludo@gnu.org \
--to=ludo@gnu.org \
--cc=28452@debbugs.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/guix.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).