[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
02/02: gexp: 'load-path-expression' produces an expression that deletes
From: |
guix-commits |
Subject: |
02/02: gexp: 'load-path-expression' produces an expression that deletes duplicates. |
Date: |
Thu, 3 Oct 2019 17:49:30 -0400 (EDT) |
civodul pushed a commit to branch master
in repository guix.
commit cdf9811d24b9c857cb79e0ddd38181862ec34bd3
Author: Ludovic Courtès <address@hidden>
Date: Thu Oct 3 22:54:28 2019 +0200
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.
---
guix/gexp.scm | 49 +++++++++++++++++++++++++++++++------------------
1 file changed, 31 insertions(+), 18 deletions(-)
diff --git a/guix/gexp.scm b/guix/gexp.scm
index e788fc5..26881ce 100644
--- a/guix/gexp.scm
+++ b/guix/gexp.scm
@@ -1527,24 +1527,37 @@ are searched for in PATH. Return #f when MODULES and
EXTENSIONS are empty."
#:module-path path
#:system system
#:target target)))
- (return (gexp (eval-when (expand load eval)
- (set! %load-path
- (cons (ungexp modules)
- (append (map (lambda (extension)
- (string-append extension
-
"/share/guile/site/"
-
(effective-version)))
- '((ungexp-native-splicing
extensions)))
- %load-path)))
- (set! %load-compiled-path
- (cons (ungexp compiled)
- (append (map (lambda (extension)
- (string-append extension
- "/lib/guile/"
-
(effective-version)
- "/site-ccache"))
- '((ungexp-native-splicing
extensions)))
- %load-compiled-path)))))))))
+ (return
+ (gexp (eval-when (expand load eval)
+ ;; Augment the load paths and delete duplicates. Do that
+ ;; without loading (srfi srfi-1) or anything.
+ (let ((extensions '((ungexp-native-splicing extensions)))
+ (prepend (lambda (items lst)
+ ;; This is O(N²) but N is typically small.
+ (let loop ((items items)
+ (lst lst))
+ (if (null? items)
+ lst
+ (loop (cdr items)
+ (cons (car items)
+ (delete (car items)
lst))))))))
+ (set! %load-path
+ (prepend (cons (ungexp modules)
+ (map (lambda (extension)
+ (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
#:key (guile (default-guile))