Add (guix describe) and use it to initialize '%package-search-path'.
* guix/describe.scm: New file. * Makefile.am (MODULES): Add it. * gnu/packages.scm (%default-package-module-path): New variable. (%package-module-path): Honor 'package-path-entries'. * build-aux/update-NEWS.scm (main): Use %DEFAULT-PACKAGE-MODULE-PATH instead of (last (%package-module-path)).
This commit is contained in:
parent
02fa1d251c
commit
fe634eaf93
|
@ -86,6 +86,7 @@ MODULES = \
|
||||||
guix/derivations.scm \
|
guix/derivations.scm \
|
||||||
guix/grafts.scm \
|
guix/grafts.scm \
|
||||||
guix/inferior.scm \
|
guix/inferior.scm \
|
||||||
|
guix/describe.scm \
|
||||||
guix/gnu-maintenance.scm \
|
guix/gnu-maintenance.scm \
|
||||||
guix/self.scm \
|
guix/self.scm \
|
||||||
guix/upstream.scm \
|
guix/upstream.scm \
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
;;; GNU Guix --- Functional package management for GNU
|
;;; GNU Guix --- Functional package management for GNU
|
||||||
;;; Copyright © 2017 Ludovic Courtès <ludo@gnu.org>
|
;;; Copyright © 2017, 2018 Ludovic Courtès <ludo@gnu.org>
|
||||||
;;;
|
;;;
|
||||||
;;; This file is part of GNU Guix.
|
;;; This file is part of GNU Guix.
|
||||||
;;;
|
;;;
|
||||||
|
@ -128,11 +128,10 @@ paragraph."
|
||||||
(define (main . args)
|
(define (main . args)
|
||||||
(match args
|
(match args
|
||||||
((news-file data-directory)
|
((news-file data-directory)
|
||||||
;; Don't browse things listed in the user's $GUIX_PACKAGE_PATH. Here we
|
;; Don't browse things listed in the user's $GUIX_PACKAGE_PATH and
|
||||||
;; assume that the last item in (%package-module-path) is the distro
|
;; in external channels.
|
||||||
;; directory.
|
|
||||||
(parameterize ((%package-module-path
|
(parameterize ((%package-module-path
|
||||||
(list (last (%package-module-path)))))
|
%default-package-module-path))
|
||||||
(define (package-file version)
|
(define (package-file version)
|
||||||
(string-append data-directory "/packages-"
|
(string-append data-directory "/packages-"
|
||||||
version ".txt"))
|
version ".txt"))
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
#:select ((package-name->name+version
|
#:select ((package-name->name+version
|
||||||
. hyphen-separated-name->name+version)))
|
. hyphen-separated-name->name+version)))
|
||||||
#:autoload (guix profiles) (packages->manifest)
|
#:autoload (guix profiles) (packages->manifest)
|
||||||
|
#:use-module (guix describe)
|
||||||
#:use-module (ice-9 vlist)
|
#:use-module (ice-9 vlist)
|
||||||
#:use-module (ice-9 match)
|
#:use-module (ice-9 match)
|
||||||
#:use-module (srfi srfi-1)
|
#:use-module (srfi srfi-1)
|
||||||
|
@ -46,6 +47,7 @@
|
||||||
%auxiliary-files-path
|
%auxiliary-files-path
|
||||||
%bootstrap-binaries-path
|
%bootstrap-binaries-path
|
||||||
%package-module-path
|
%package-module-path
|
||||||
|
%default-package-module-path
|
||||||
|
|
||||||
fold-packages
|
fold-packages
|
||||||
|
|
||||||
|
@ -130,22 +132,31 @@ for system '~a'")
|
||||||
("gnu/packages.scm" gnu/)
|
("gnu/packages.scm" gnu/)
|
||||||
("guix.scm"))))
|
("guix.scm"))))
|
||||||
|
|
||||||
|
(define %default-package-module-path
|
||||||
|
;; Default search path for package modules.
|
||||||
|
`((,%distro-root-directory . "gnu/packages")))
|
||||||
|
|
||||||
(define %package-module-path
|
(define %package-module-path
|
||||||
;; Search path for package modules. Each item must be either a directory
|
;; 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
|
;; name or a pair whose car is a directory and whose cdr is a sub-directory
|
||||||
;; to narrow the search.
|
;; to narrow the search.
|
||||||
(let* ((not-colon (char-set-complement (char-set #\:)))
|
(let* ((not-colon (char-set-complement (char-set #\:)))
|
||||||
(environment (string-tokenize (or (getenv "GUIX_PACKAGE_PATH") "")
|
(environment (string-tokenize (or (getenv "GUIX_PACKAGE_PATH") "")
|
||||||
not-colon)))
|
not-colon))
|
||||||
;; Automatically add items from $GUIX_PACKAGE_PATH to Guile's search path.
|
(channels (package-path-entries)))
|
||||||
(for-each (lambda (directory)
|
;; Automatically add channels and items from $GUIX_PACKAGE_PATH to Guile's
|
||||||
(set! %load-path (cons directory %load-path))
|
;; search path. For historical reasons, $GUIX_PACKAGE_PATH goes to the
|
||||||
(set! %load-compiled-path
|
;; front; channels go to the back so that they don't override Guix' own
|
||||||
(cons directory %load-compiled-path)))
|
;; modules.
|
||||||
environment)
|
(set! %load-path
|
||||||
|
(append environment %load-path channels))
|
||||||
|
(set! %load-compiled-path
|
||||||
|
(append environment %load-compiled-path channels))
|
||||||
|
|
||||||
(make-parameter
|
(make-parameter
|
||||||
(append environment `((,%distro-root-directory . "gnu/packages"))))))
|
(append environment
|
||||||
|
%default-package-module-path
|
||||||
|
channels))))
|
||||||
|
|
||||||
(define %patch-path
|
(define %patch-path
|
||||||
;; Define it after '%package-module-path' so that '%load-path' contains user
|
;; Define it after '%package-module-path' so that '%load-path' contains user
|
||||||
|
|
|
@ -0,0 +1,73 @@
|
||||||
|
;;; GNU Guix --- Functional package management for GNU
|
||||||
|
;;; Copyright © 2018 Ludovic Courtès <ludo@gnu.org>
|
||||||
|
;;;
|
||||||
|
;;; This file is part of GNU Guix.
|
||||||
|
;;;
|
||||||
|
;;; GNU Guix is free software; you can redistribute it and/or modify it
|
||||||
|
;;; under the terms of the GNU General Public License as published by
|
||||||
|
;;; the Free Software Foundation; either version 3 of the License, or (at
|
||||||
|
;;; your option) any later version.
|
||||||
|
;;;
|
||||||
|
;;; GNU Guix is distributed in the hope that it will be useful, but
|
||||||
|
;;; WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
;;; GNU General Public License for more details.
|
||||||
|
;;;
|
||||||
|
;;; You should have received a copy of the GNU General Public License
|
||||||
|
;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
(define-module (guix describe)
|
||||||
|
#:use-module (guix memoization)
|
||||||
|
#:use-module (guix profiles)
|
||||||
|
#:use-module (srfi srfi-1)
|
||||||
|
#:use-module (ice-9 match)
|
||||||
|
#:export (package-path-entries))
|
||||||
|
|
||||||
|
;;; Commentary:
|
||||||
|
;;;
|
||||||
|
;;; This module provides supporting code to allow a Guix instance to find, at
|
||||||
|
;;; run time, which profile it's in (profiles created by 'guix pull'). That
|
||||||
|
;;; allows it to read meta-information about itself (e.g., repository URL and
|
||||||
|
;;; commit ID) and to find other channels available in the same profile. It's
|
||||||
|
;;; a bit like ELPA's pkg-info.el.
|
||||||
|
;;;
|
||||||
|
;;; Code:
|
||||||
|
|
||||||
|
(define current-profile
|
||||||
|
(mlambda ()
|
||||||
|
"Return the profile (created by 'guix pull') the calling process lives in,
|
||||||
|
or #f if this is not applicable."
|
||||||
|
(match (command-line)
|
||||||
|
((program . _)
|
||||||
|
(and (string-suffix? "/bin/guix" program)
|
||||||
|
;; Note: We want to do _lexical dot-dot resolution_. Using ".."
|
||||||
|
;; for real would instead take us into the /gnu/store directory
|
||||||
|
;; that ~/.config/guix/current/bin points to, whereas we want to
|
||||||
|
;; obtain ~/.config/guix/current.
|
||||||
|
(let ((candidate (dirname (dirname program))))
|
||||||
|
(and (file-exists? (string-append candidate "/manifest"))
|
||||||
|
candidate)))))))
|
||||||
|
|
||||||
|
(define current-profile-entries
|
||||||
|
(mlambda ()
|
||||||
|
"Return the list of entries in the 'guix pull' profile the calling process
|
||||||
|
lives in, or #f if this is not applicable."
|
||||||
|
(match (current-profile)
|
||||||
|
(#f '())
|
||||||
|
(profile
|
||||||
|
(let ((manifest (profile-manifest profile)))
|
||||||
|
(manifest-entries manifest))))))
|
||||||
|
|
||||||
|
(define package-path-entries
|
||||||
|
(mlambda ()
|
||||||
|
"Return a list of package path entries to be added to the package search
|
||||||
|
path. These entries are taken from the 'guix pull' profile the calling
|
||||||
|
process lives in, when applicable."
|
||||||
|
;; Filter out Guix itself.
|
||||||
|
(filter-map (lambda (entry)
|
||||||
|
(and (not (string=? (manifest-entry-name entry)
|
||||||
|
"guix"))
|
||||||
|
(string-append (manifest-entry-item entry)
|
||||||
|
"/share/guile/site/"
|
||||||
|
(effective-version))))
|
||||||
|
(current-profile-entries))))
|
Loading…
Reference in New Issue