unofficial mirror of guix-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Christopher Baines <mail@cbaines.net>
To: guix-devel@gnu.org
Subject: Subdirectories in GUIX_PACKAGE_PATH
Date: Fri, 23 Jun 2017 21:20:58 +0100	[thread overview]
Message-ID: <20170623212058.638c6de8@cbaines.net> (raw)


[-- Attachment #1.1: Type: text/plain, Size: 1861 bytes --]

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

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.2: 0001-gnu-packages-Support-subdirectories-in-GUIX_PACKAGE_.patch --]
[-- Type: text/x-patch, Size: 2595 bytes --]

From eb859e7866e38b8fb19b1aa14ccd85c5375feff0 Mon Sep 17 00:00:00 2001
From: Christopher Baines <mail@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


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 963 bytes --]

             reply	other threads:[~2017-06-23 20:21 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-23 20:20 Christopher Baines [this message]
2017-06-24 19:13 ` Subdirectories in GUIX_PACKAGE_PATH Alex Kost
2017-06-26 11:22 ` Ricardo Wurmus
2017-06-26 20:15   ` Christopher Baines
2017-06-30  9:35   ` Ludovic Courtès
2017-07-03 18:15     ` Alex Kost
2017-07-03 21:53       ` Ludovic Courtès
2017-07-05  7:04         ` Alex Kost

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170623212058.638c6de8@cbaines.net \
    --to=mail@cbaines.net \
    --cc=guix-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).