From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ricardo Wurmus Subject: bug#22629: [PATCH v2 2/3] Add (guix describe) and use it to initialize '%package-search-path'. Date: Fri, 31 Aug 2018 14:21:30 +0200 Message-ID: <87k1o620c5.fsf@elephly.net> References: <87lg8nr1ab.fsf@gnu.org> <20180830213152.3404-1-ludo@gnu.org> <20180830213152.3404-2-ludo@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:39569) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fviS9-0008OV-1B for bug-guix@gnu.org; Fri, 31 Aug 2018 08:23:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fviS6-0000BM-2g for bug-guix@gnu.org; Fri, 31 Aug 2018 08:23:04 -0400 Received: from debbugs.gnu.org ([208.118.235.43]:34854) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fviS5-0000BI-UZ for bug-guix@gnu.org; Fri, 31 Aug 2018 08:23:01 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1fviS5-0001e5-NB for bug-guix@gnu.org; Fri, 31 Aug 2018 08:23:01 -0400 Sender: "Debbugs-submit" Resent-Message-ID: In-reply-to: <20180830213152.3404-2-ludo@gnu.org> List-Id: Bug reports for GNU Guix List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-guix-bounces+gcggb-bug-guix=m.gmane.org@gnu.org Sender: "bug-Guix" To: Ludovic =?UTF-8?Q?Court=C3=A8s?= Cc: 22629@debbugs.gnu.org Hi Ludo, > * 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)). > --- [=E2=80=A6] > +(define %default-package-module-path > + ;; Default search path for package modules. > + `((,%distro-root-directory . "gnu/packages"))) > + > (define %package-module-path > ;; Search path for package modules. Each item must be either a direct= ory > ;; name or a pair whose car is a directory and whose cdr is a sub-dire= ctory > ;; to narrow the search. > (let* ((not-colon (char-set-complement (char-set #\:))) > (environment (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) > + not-colon)) > + (channels (package-path-entries))) > + ;; Automatically add channels and items from $GUIX_PACKAGE_PATH to G= uile's > + ;; search path. For historical reasons, $GUIX_PACKAGE_PATH goes to = the > + ;; front; channels go to the back so that they don't override Guix' = own > + ;; modules. > + (set! %load-path > + (append environment %load-path channels)) > + (set! %load-compiled-path > + (append environment %load-compiled-path channels)) > > (make-parameter > - (append environment `((,%distro-root-directory . "gnu/packages"))))= )) > + (append environment > + %default-package-module-path > + channels)))) I=E2=80=99m not sure I understand the reason to add channels to the end of = the search path. Could it not be desirable in some use-cases to override certain Guix modules? Should the order be made explicit in the channel to avoid having to accomodate =E2=80=9Chistorical reasons=E2=80=9D in the f= uture? :) Putting them at the end probably ensures that Guix itself won=E2=80=99t bre= ak and can thus be rolled back. > diff --git a/guix/describe.scm b/guix/describe.scm > new file mode 100644 > index 000000000..3122a762f > --- /dev/null > +++ b/guix/describe.scm [=E2=80=A6] > +(define current-profile > + (mlambda () > + "Return the profile (created by 'guix pull') the calling process liv= es 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 direct= ory > + ;; that ~/.config/guix/current/bin points to, whereas we wan= t to > + ;; obtain ~/.config/guix/current. > + (let ((candidate (dirname (dirname program)))) > + (and (file-exists? (string-append candidate "/manifest")) > + candidate))))))) I don=E2=80=99t know=E2=80=A6 there=E2=80=99s something about this file sys= tem traversal that doesn=E2=80=99t sit right with me. I=E2=80=99m not sure about (command-lin= e) =E2=80=94 when =E2=80=A6/bin/guix is executed by a wrapper, will the wrapper be the =E2=80= =9Cprogram=E2=80=9D that we match against or the target? (This is a concern for wrappers that set up site-wide default channels or a remote daemon, for example.) -- Ricardo