diff options
-rw-r--r-- | guix-build-coordinator/agent.scm | 37 |
1 files changed, 23 insertions, 14 deletions
diff --git a/guix-build-coordinator/agent.scm b/guix-build-coordinator/agent.scm index 3e0e9ac..1eb0d58 100644 --- a/guix-build-coordinator/agent.scm +++ b/guix-build-coordinator/agent.scm @@ -53,21 +53,30 @@ (define (pre-build-process derivation-name) (define (find-missing-inputs inputs) - (let ((output-paths - (append-map derivation-input-output-paths inputs))) + (let* ((output-paths + (append-map derivation-input-output-paths inputs)) + (missing-paths + (remove file-exists? output-paths)) + (path-substitutes + (with-store store + (map (lambda (file) + (has-substitutes? store file)) + missing-paths)))) - (with-store store - (fold (lambda (file result) - (if (file-exists? file) - result - (if (has-substitutes? store file) - (begin - (with-store store - (build-things store output-paths)) - result) - (cons file result)))) - '() - output-paths)))) + (if (member #f path-substitutes) + (fold (lambda (file substitute-available? result) + (if substitute-available? + result + (cons file result))) + '() + missing-paths + path-substitutes) + (begin + ;; Download the substitutes + (with-store store + (build-things store missing-paths)) + + '())))) (let ((derivation (if (file-exists? derivation-name) |