From mboxrd@z Thu Jan 1 00:00:00 1970 From: ludo@gnu.org (Ludovic =?UTF-8?Q?Court=C3=A8s?=) Subject: bug#22629: [PATCH v2 2/3] Add (guix describe) and use it to initialize '%package-search-path'. Date: Fri, 31 Aug 2018 15:56:33 +0200 Message-ID: <87a7p2od0u.fsf@gnu.org> References: <87lg8nr1ab.fsf@gnu.org> <20180830213152.3404-1-ludo@gnu.org> <20180830213152.3404-2-ludo@gnu.org> <87k1o620c5.fsf@elephly.net> 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]:38076) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fvjv8-0000H9-NJ for bug-guix@gnu.org; Fri, 31 Aug 2018 09:57:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fvjv5-00030u-GL for bug-guix@gnu.org; Fri, 31 Aug 2018 09:57:06 -0400 Received: from debbugs.gnu.org ([208.118.235.43]:35713) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fvjv5-00030o-CK for bug-guix@gnu.org; Fri, 31 Aug 2018 09:57:03 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1fvjv5-0004IA-AY for bug-guix@gnu.org; Fri, 31 Aug 2018 09:57:03 -0400 Sender: "Debbugs-submit" Resent-Message-ID: In-Reply-To: <87k1o620c5.fsf@elephly.net> (Ricardo Wurmus's message of "Fri, 31 Aug 2018 14:21:30 +0200") 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: Ricardo Wurmus Cc: 22629@debbugs.gnu.org Hi Ricardo, Ricardo Wurmus skribis: >> (define %package-module-path >> ;; Search path for package modules. Each item must be either a direc= tory >> ;; name or a pair whose car is a directory and whose cdr is a sub-dir= ectory >> ;; 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 searc= h 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 = Guile'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 o= f 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= future? :) For %load-path and %load-compiled-path, I thought it may be safer to always keep Guix in front of the rest. It means that channels cannot override, say, (guix scripts package) or (guix derivations) or (gnu packages base). That=E2=80=99s mostly to be on the safe side, and because I think this is not =E2=80=9Cthe right way=E2=80=9D to customize things; it= =E2=80=99d be just too brittle. Regarding %package-module-path itself, whether channels come first or not doesn=E2=80=99t actually make much of a difference at this point since =E2=80=98fold-packages=E2=80=99 traverses everything anyway. Maybe in the = future =E2=80=98fold-packages=E2=80=99 could make some distinction though. Dunno. >> 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 li= ves 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 direc= tory >> + ;; that ~/.config/guix/current/bin points to, whereas we wa= nt 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 s= ystem traversal that > doesn=E2=80=99t sit right with me. I=E2=80=99m not sure about (command-l= ine) =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.) The =E2=80=98guix=E2=80=99 command is a script starting with: #!/gnu/store/=E2=80=A6-guile-2.2.4/bin/guile --no-auto-compile =E2=80=98guile=E2=80=99 receives the =E2=80=98guix=E2=80=99 file name as it= s argv[1]. Since the =E2=80=98guix=E2=80=99 file name was passed as the first argument to =E2=80=98execve=E2=80=99, it = is necessarily valid (either it=E2=80=99s relative to $PWD or, in the likely c= ase where =E2=80=98guix=E2=80=99 was searched for in $PATH, it=E2=80=99s an abs= olute file name.) In addition (ice-9 command-line) arranges to make the first non-hyphen argument the first element of what =E2=80=98command-line=E2=80=99 returns. If you have a wrapper that execs =E2=80=98guix=E2=80=99 or whatever, it=E2= =80=99ll still work. Of course, the trick doesn=E2=80=99t work if you do things like: guile -L ~/.config/guix/current/share/guile/site/2.2 but I think that=E2=80=99s OK. (I hadn=E2=80=99t realized the trick about execve=E2=80=99s first argument = becoming a valid file name in the interpreter=E2=80=99s argv[1]. Handy!) Ludo=E2=80=99.