diff options
| author | Ludovic Courtès <ludo@gnu.org> | 2018-01-21 00:05:09 +0100 |
|---|---|---|
| committer | Ludovic Courtès <ludo@gnu.org> | 2018-01-21 00:24:03 +0100 |
| commit | d466b1fc8221a6224fe7ded53a828f9c29ed9457 (patch) | |
| tree | 5180831a10c380d7eca1e8c0abc5b09d49a3a38c /tests/services.scm | |
| parent | bc58201ec22aeb07b61dc1e482d6a57868436eef (diff) | |
services: Missing services are automatically instantiated.
This simplifies OS configuration: users no longer need to be aware of
what a given service depends on.
See the discussion at
<https://lists.gnu.org/archive/html/guix-devel/2018-01/msg00114.html>.
* gnu/services.scm (missing-target-error): New procedure.
(service-back-edges): Use it.
(instantiate-missing-services): New procedure.
* gnu/system.scm (operating-system-services): Call
'instantiate-missing-services'.
* tests/services.scm ("instantiate-missing-services")
("instantiate-missing-services, no default value"): New tests.
* gnu/services/version-control.scm (cgit-service-type)[extensions]: Add
FCGIWRAP-SERVICE-TYPE.
* gnu/tests/version-control.scm (%cgit-os): Remove NGINX-SERVICE-TYPE
and FCGIWRAP-SERVICE-TYPE instances.
* doc/guix.texi (Log Rotation): Remove 'mcron-service-type' in example.
(Miscellaneous Services): Remove 'nginx-service-type' and
'fcgiwrap-service-type' in Cgit example.
Diffstat (limited to 'tests/services.scm')
| -rw-r--r-- | tests/services.scm | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/tests/services.scm b/tests/services.scm index ca32b565c49..b146a0dec2a 100644 --- a/tests/services.scm +++ b/tests/services.scm | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | ;;; GNU Guix --- Functional package management for GNU | 1 | ;;; GNU Guix --- Functional package management for GNU |
| 2 | ;;; Copyright © 2015, 2016, 2017 Ludovic Courtès <ludo@gnu.org> | 2 | ;;; Copyright © 2015, 2016, 2017, 2018 Ludovic Courtès <ludo@gnu.org> |
| 3 | ;;; | 3 | ;;; |
| 4 | ;;; This file is part of GNU Guix. | 4 | ;;; This file is part of GNU Guix. |
| 5 | ;;; | 5 | ;;; |
| @@ -122,6 +122,36 @@ | |||
| 122 | (fold-services (list s) #:target-type t1) | 122 | (fold-services (list s) #:target-type t1) |
| 123 | #f))) | 123 | #f))) |
| 124 | 124 | ||
| 125 | (test-assert "instantiate-missing-services" | ||
| 126 | (let* ((t1 (service-type (name 't1) (extensions '()) | ||
| 127 | (default-value 'dflt) | ||
| 128 | (compose concatenate) | ||
| 129 | (extend cons))) | ||
| 130 | (t2 (service-type (name 't2) | ||
| 131 | (extensions | ||
| 132 | (list (service-extension t1 list))))) | ||
| 133 | (s1 (service t1 'hey!)) | ||
| 134 | (s2 (service t2 42))) | ||
| 135 | (and (lset= equal? | ||
| 136 | (list (service t1) s2) | ||
| 137 | (instantiate-missing-services (list s2))) | ||
| 138 | (equal? (list s1 s2) | ||
| 139 | (instantiate-missing-services (list s1 s2)))))) | ||
| 140 | |||
| 141 | (test-assert "instantiate-missing-services, no default value" | ||
| 142 | (let* ((t1 (service-type (name 't1) (extensions '()))) | ||
| 143 | (t2 (service-type (name 't2) | ||
| 144 | (extensions | ||
| 145 | (list (service-extension t1 list))))) | ||
| 146 | (s (service t2 42))) | ||
| 147 | (guard (c ((missing-target-service-error? c) | ||
| 148 | (and (eq? (missing-target-service-error-target-type c) | ||
| 149 | t1) | ||
| 150 | (eq? (missing-target-service-error-service c) | ||
| 151 | s)))) | ||
| 152 | (instantiate-missing-services (list s)) | ||
| 153 | #f))) | ||
| 154 | |||
| 125 | (test-assert "shepherd-service-lookup-procedure" | 155 | (test-assert "shepherd-service-lookup-procedure" |
| 126 | (let* ((s1 (shepherd-service (provision '(s1 s1b)) (start #f))) | 156 | (let* ((s1 (shepherd-service (provision '(s1 s1b)) (start #f))) |
| 127 | (s2 (shepherd-service (provision '(s2 s2b)) (start #f))) | 157 | (s2 (shepherd-service (provision '(s2 s2b)) (start #f))) |
