services: Add 'file-system-service'.
[jackhill/guix/guix.git] / gnu / services / dmd.scm
1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2013, 2014 Ludovic Courtès <ludo@gnu.org>
3 ;;;
4 ;;; This file is part of GNU Guix.
5 ;;;
6 ;;; GNU Guix is free software; you can redistribute it and/or modify it
7 ;;; under the terms of the GNU General Public License as published by
8 ;;; the Free Software Foundation; either version 3 of the License, or (at
9 ;;; your option) any later version.
10 ;;;
11 ;;; GNU Guix is distributed in the hope that it will be useful, but
12 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
13 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 ;;; GNU General Public License for more details.
15 ;;;
16 ;;; You should have received a copy of the GNU General Public License
17 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
18
19 (define-module (gnu services dmd)
20 #:use-module (guix gexp)
21 #:use-module (guix monads)
22 #:use-module (gnu services)
23 #:use-module (ice-9 match)
24 #:use-module (srfi srfi-1)
25 #:export (dmd-configuration-file))
26
27 ;;; Commentary:
28 ;;;
29 ;;; Instantiating system services as a dmd configuration file.
30 ;;;
31 ;;; Code:
32
33 (define (dmd-configuration-file services)
34 "Return the dmd configuration file for SERVICES."
35 (define modules
36 ;; Extra modules visible to dmd.conf.
37 '((guix build syscalls)
38 (guix build linux-initrd)
39 (guix build utils)))
40
41 (mlet %store-monad ((modules (imported-modules modules))
42 (compiled (compiled-modules modules)))
43 (define config
44 #~(begin
45 (eval-when (expand load eval)
46 (set! %load-path (cons #$modules %load-path))
47 (set! %load-compiled-path
48 (cons #$compiled %load-compiled-path)))
49
50 (use-modules (ice-9 ftw)
51 (guix build syscalls)
52 ((guix build linux-initrd)
53 #:select (check-file-system)))
54
55 (register-services
56 #$@(map (lambda (service)
57 #~(make <service>
58 #:docstring '#$(service-documentation service)
59 #:provides '#$(service-provision service)
60 #:requires '#$(service-requirement service)
61 #:respawn? '#$(service-respawn? service)
62 #:start #$(service-start service)
63 #:stop #$(service-stop service)))
64 services))
65
66 ;; guix-daemon 0.6 aborts if 'PATH' is undefined, so work around it.
67 (setenv "PATH" "/run/current-system/bin")
68
69 (format #t "starting services...~%")
70 (for-each start '#$(append-map service-provision services))))
71
72 (gexp->file "dmd.conf" config)))
73
74 ;;; dmd.scm ends here