Commit | Line | Data |
---|---|---|
db4fdc04 LC |
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) | |
b5f4e686 | 20 | #:use-module (guix gexp) |
db4fdc04 LC |
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 | ||
4dfe6c58 LC |
33 | (define (dmd-configuration-file services) |
34 | "Return the dmd configuration file for SERVICES." | |
23ed63a1 LC |
35 | (define modules |
36 | ;; Extra modules visible to dmd.conf. | |
023f391c | 37 | '((guix build syscalls) |
e2f4b305 | 38 | (gnu build file-systems) |
023f391c | 39 | (guix build utils))) |
23ed63a1 LC |
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) | |
023f391c | 51 | (guix build syscalls) |
83a17b62 | 52 | (guix build utils) |
e2f4b305 | 53 | ((gnu build file-systems) |
d4c87617 | 54 | #:select (check-file-system canonicalize-device-spec))) |
23ed63a1 LC |
55 | |
56 | (register-services | |
57 | #$@(map (lambda (service) | |
58 | #~(make <service> | |
59 | #:docstring '#$(service-documentation service) | |
60 | #:provides '#$(service-provision service) | |
61 | #:requires '#$(service-requirement service) | |
62 | #:respawn? '#$(service-respawn? service) | |
63 | #:start #$(service-start service) | |
64 | #:stop #$(service-stop service))) | |
65 | services)) | |
66 | ||
67 | ;; guix-daemon 0.6 aborts if 'PATH' is undefined, so work around it. | |
b4140694 | 68 | (setenv "PATH" "/run/current-system/profile/bin") |
23ed63a1 LC |
69 | |
70 | (format #t "starting services...~%") | |
fdaacbad LC |
71 | (for-each start |
72 | '#$(append-map service-provision | |
73 | (filter service-auto-start? services))))) | |
23ed63a1 LC |
74 | |
75 | (gexp->file "dmd.conf" config))) | |
db4fdc04 LC |
76 | |
77 | ;;; dmd.scm ends here |