diff --git a/guix/scripts/lint.scm b/guix/scripts/lint.scm index 9920c3ee62..6d9b9e96a9 100644 --- a/guix/scripts/lint.scm +++ b/guix/scripts/lint.scm @@ -209,23 +209,31 @@ (define (parse-options) (list-checkers-and-exit checkers)) (with-error-handling - (let ((any-lint-checker-requires-store? - (any lint-checker-requires-store? checkers))) + (let ((store-needed? (any lint-checker-requires-store? checkers))) - (define (call-maybe-with-store proc) - (if any-lint-checker-requires-store? - (with-store store - (proc store)) - (proc #f))) - - (call-maybe-with-store - (lambda (store) - (cond - ((null? args) - (fold-packages (lambda (p r) (run-checkers p checkers - #:store store)) '())) - (else - (for-each (lambda (package) - (run-checkers package checkers - #:store store)) - args))))))))) + (cond + ((null? args) + (let loop ((packages (fold-packages cons '())) + (processed 0) + (store #f)) + (match packages + ((package . rest) + (let ((store (and store-needed? + (if store + ;; XXX: Periodically start a new session + ;; with empty caches to avoid unbounded + ;; heap growth caused by the 'derivation' + ;; checker. + (if (zero? (modulo processed 1000)) + (begin + (close-connection store) + (open-connection)) + store) + (open-connection))))) + (run-checkers package checkers #:store store) + (loop rest (+ 1 processed) store)))))) + (else + (for-each (lambda (package) + (run-checkers package checkers + #:store store)) + args)))))))