summary refs log tree commit diff
path: root/gnu/packages.scm
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2018-03-23 15:36:12 +0100
committerLudovic Courtès <ludo@gnu.org>2018-04-08 17:41:08 +0200
commiteaae07ec2878707744fed76029a28ab9a494fc2e (patch)
tree6c2cd2dfec1d1f2aa951dcc66907d0c1cbfac137 /gnu/packages.scm
parent278c16579dfe59833155b1e7678a727e60fa6540 (diff)
downloadguix-eaae07ec2878707744fed76029a28ab9a494fc2e.tar.gz
Add (guix self).
* guix/self.scm: New file.
* Makefile.am (MODULES): Add it.
* gnu/packages.scm (%distro-root-directory): Rewrite to try different
directories.
* guix/discovery.scm (guix): Export 'scheme-files'.
Diffstat (limited to 'gnu/packages.scm')
-rw-r--r--gnu/packages.scm21
1 files changed, 19 insertions, 2 deletions
diff --git a/gnu/packages.scm b/gnu/packages.scm
index 97e6cb347f..44a56dfde0 100644
--- a/gnu/packages.scm
+++ b/gnu/packages.scm
@@ -110,8 +110,25 @@ for system '~a'")
                         file-name system)))))))
 
 (define %distro-root-directory
-  ;; Absolute file name of the module hierarchy.
-  (dirname (search-path %load-path "guix.scm")))
+  ;; Absolute file name of the module hierarchy.  Since (gnu packages …) might
+  ;; live in a directory different from (guix), try to get the best match.
+  (letrec-syntax ((dirname* (syntax-rules ()
+                              ((_ file)
+                               (dirname file))
+                              ((_ file head tail ...)
+                               (dirname (dirname* file tail ...)))))
+                  (try      (syntax-rules ()
+                              ((_ (file things ...) rest ...)
+                               (match (search-path %load-path file)
+                                 (#f
+                                  (try rest ...))
+                                 (absolute
+                                  (dirname* absolute things ...))))
+                              ((_)
+                               #f))))
+    (try ("gnu/packages/base.scm" gnu/ packages/)
+         ("gnu/packages.scm"      gnu/)
+         ("guix.scm"))))
 
 (define %package-module-path
   ;; Search path for package modules.  Each item must be either a directory