From eb859e7866e38b8fb19b1aa14ccd85c5375feff0 Mon Sep 17 00:00:00 2001 From: Christopher Baines Date: Fri, 23 Jun 2017 20:53:10 +0100 Subject: [PATCH] gnu: packages: Support subdirectories in GUIX_PACKAGE_PATH * gnu/packages.scm (%package-module-path): Treat anything after ^ within each element of the GUIX_PACKAGE_PATH as a subdirectory. --- gnu/packages.scm | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/gnu/packages.scm b/gnu/packages.scm index 562906178..25be89c87 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 -- 2.13.1