Hey, Recently I had problems with the way GUIX_PACKAGE_PATH was working with govuk-guix [1]. Currently, I'm using a separate directory for the GUIX_PACKAGE_PATH that contains symlinks to a subset of the Guile modules necessary for the packages in the repository.
I think support (whether intentional or otherwise) for this approach was removed in [2]. While I could get it working again by just symlinking all the files individually, it reminded me that there was the possibility of improving GUIX_PACKAGE_PATH. The reason I'm separating the package search path from the complete set of modules is linked to the current way I've approached making govuk-guix work reproducibly in terms of the version of Guix itself. The govuk-guix repository includes a Guix package definition that points at a specific revision of Guix. The guix environment command is used to setup this Guix package, at which point the behaviour should be independent of the Guix on the system that was used at first. The script to do this is here [3]. Guix itself does something similar for the package definitions, as it only looks in (gnu packages). I'm unsure what the motivation is for this, maybe its faster just to check modules that are known to contain packages. Anyway, given the above, I think it would be useful to support specifying subdirectories when using GUIX_PACKAGE_PATH. Any thoughts? I've attached a rough patch that sets this up, such that you can do something like: export GUIX_PACKAGE_PATH="/tmp/foo^bar/baz:/tmp/cats" Where ^ acts as the separator, and bar/baz is the subdirectory. Thanks, Chris 1: https://github.com/alphagov/govuk-guix 2: https://git.savannah.gnu.org/cgit/guix.git/commit/?id=d27cc3bfaafe6b5b0831e88afb1c46311d382a0b 3: https://github.com/alphagov/govuk-guix/blob/master/guix-pre-inst-env
From eb859e7866e38b8fb19b1aa14ccd85c5375feff0 Mon Sep 17 00:00:00 2001 From: Christopher Baines <m...@cbaines.net> 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
pgp2F26P5IwlH.pgp
Description: OpenPGP digital signature