diff options
-rw-r--r-- | gnu/packages.scm | 27 |
1 files changed, 22 insertions, 5 deletions
diff --git a/gnu/packages.scm b/gnu/packages.scm index 5629061788..25be89c879 100644 --- a/gnu/packages.scm +++ b/gnu/packages.scm @@ -117,18 +117,35 @@ for system '~a'") ;; Search path for package modules. Each item must be either a directory ;; name or a pair whose car is a directory and whose cdr is a sub-directory ;; to narrow the search. - (let* ((not-colon (char-set-complement (char-set #\:))) - (environment (string-tokenize (or (getenv "GUIX_PACKAGE_PATH") "") - not-colon))) + (let* ((not-colon (char-set-complement (char-set #\:))) + (not-caret (char-set-complement (char-set #\^))) + (path-elements-from-environment + (map + (lambda (path-element) + (match (string-tokenize path-element not-caret) + ((dir) dir) + ((dir sub) (cons dir sub)) + ((dir sub rest ...) + (leave + (G_ "%package-module-path: GUIX_PACKAGE_PATH element \"~A\" + does not match form \"directory[^sub-directory]\".") + path-element)))) + (string-tokenize (or (getenv "GUIX_PACKAGE_PATH") "") + not-colon)))) + ;; Automatically add items from $GUIX_PACKAGE_PATH to Guile's search path. (for-each (lambda (directory) (set! %load-path (cons directory %load-path)) (set! %load-compiled-path (cons directory %load-compiled-path))) - environment) + (map (match-lambda + (directory directory) + ((directory sub-directory) directory)) + path-elements-from-environment)) (make-parameter - (append environment `((,%distro-root-directory . "gnu/packages")))))) + `(,@path-elements-from-environment + (,%distro-root-directory . "gnu/packages"))))) (define %patch-path ;; Define it after '%package-module-path' so that '%load-path' contains user |