gexp: 'load-path-expression' produces an expression that deletes duplicates.

Fixes <https://bugs.gnu.org/37531>.

"herd eval root '(length %load-path)'" on a freshly-booted bare-bones
system now returns 8 instead of 119 before.

* guix/gexp.scm (load-path-expression): Rewrite expression to that it
deletes duplicates.
This commit is contained in:
Ludovic Courtès 2019-10-03 22:54:28 +02:00
parent 5a02f8e384
commit cdf9811d24
No known key found for this signature in database
GPG Key ID: 090B11993D9AEBB5
1 changed files with 31 additions and 18 deletions

View File

@ -1527,24 +1527,37 @@ are searched for in PATH. Return #f when MODULES and EXTENSIONS are empty."
#:module-path path #:module-path path
#:system system #:system system
#:target target))) #:target target)))
(return (gexp (eval-when (expand load eval) (return
(set! %load-path (gexp (eval-when (expand load eval)
(cons (ungexp modules) ;; Augment the load paths and delete duplicates. Do that
(append (map (lambda (extension) ;; without loading (srfi srfi-1) or anything.
(string-append extension (let ((extensions '((ungexp-native-splicing extensions)))
"/share/guile/site/" (prepend (lambda (items lst)
(effective-version))) ;; This is O(N²) but N is typically small.
'((ungexp-native-splicing extensions))) (let loop ((items items)
%load-path))) (lst lst))
(set! %load-compiled-path (if (null? items)
(cons (ungexp compiled) lst
(append (map (lambda (extension) (loop (cdr items)
(string-append extension (cons (car items)
"/lib/guile/" (delete (car items) lst))))))))
(effective-version) (set! %load-path
"/site-ccache")) (prepend (cons (ungexp modules)
'((ungexp-native-splicing extensions))) (map (lambda (extension)
%load-compiled-path))))))))) (string-append extension
"/share/guile/site/"
(effective-version)))
extensions))
%load-path))
(set! %load-compiled-path
(prepend (cons (ungexp compiled)
(map (lambda (extension)
(string-append extension
"/lib/guile/"
(effective-version)
"/site-ccache"))
extensions))
%load-compiled-path)))))))))
(define* (gexp->script name exp (define* (gexp->script name exp
#:key (guile (default-guile)) #:key (guile (default-guile))