diff options
author | Ludovic Courtès <ludo@gnu.org> | 2018-09-07 23:00:39 +0200 |
---|---|---|
committer | Ludovic Courtès <ludo@gnu.org> | 2018-09-07 23:00:39 +0200 |
commit | 9b6c4355645534d1ae799bfef6761b75ed8b3a41 (patch) | |
tree | 7d36556a55c5daded689ef86e33b3b31a2763070 /gnu | |
parent | 9f1f200c0462d5fa798e4d7b8c3c09294f8bfb95 (diff) |
services: 'instantiate-missing-services' reaches fixed point.
Fixes a bug whereby services indirectly depended on would not be
automatically instantiated.
* gnu/services.scm (instantiate-missing-services): Loop back when the
length of ADJUSTED is greater than that of INSTANCES.
* tests/services.scm ("instantiate-missing-services, indirect"): New test.
Diffstat (limited to 'gnu')
-rw-r--r-- | gnu/services.scm | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/gnu/services.scm b/gnu/services.scm index 49cf01a4f8..f151bbaa9d 100644 --- a/gnu/services.scm +++ b/gnu/services.scm @@ -732,13 +732,23 @@ instantiated; other missing services lead to a instances (service-type-extensions (service-kind svc)))) - (let ((instances (fold (lambda (service result) - (vhash-consq (service-kind service) service - result)) - vlist-null services))) - (fold2 adjust-service-list - services instances - services))) + (let loop ((services services)) + (define instances + (fold (lambda (service result) + (vhash-consq (service-kind service) service + result)) + vlist-null services)) + + (define adjusted + (fold2 adjust-service-list + services instances + services)) + + ;; If we instantiated services, they might in turn depend on missing + ;; services. Loop until we've reached fixed point. + (if (= (length adjusted) (vlist-length instances)) + adjusted + (loop adjusted)))) (define* (fold-services services #:key (target-type system-service-type)) |