From mboxrd@z Thu Jan 1 00:00:00 1970 From: =?UTF-8?Q?=E5=AE=8B=E6=96=87=E6=AD=A6?= Subject: bug#20255: 'search-paths' should respect both user and system profile. Date: Tue, 05 May 2015 16:28:53 +0800 Message-ID: <87k2wnqvga.fsf@gmail.com> References: <877ftschjt.fsf@gmail.com> <87fv8fip01.fsf@gnu.org> <87d23j1bxk.fsf@gmail.com> <87lhh43tn0.fsf@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]:54288) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YpYF3-0006UX-DH for bug-guix@gnu.org; Tue, 05 May 2015 04:30:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YpYEw-0006hJ-N8 for bug-guix@gnu.org; Tue, 05 May 2015 04:30:13 -0400 Received: from debbugs.gnu.org ([140.186.70.43]:52575) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YpYEw-0006gW-IC for bug-guix@gnu.org; Tue, 05 May 2015 04:30:06 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1YpYEu-0000Pg-KP for bug-guix@gnu.org; Tue, 05 May 2015 04:30:04 -0400 Sender: "Debbugs-submit" Resent-Message-ID: In-Reply-To: <87lhh43tn0.fsf@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-bounces+gcggb-bug-guix=m.gmane.org@gnu.org To: Ludovic =?UTF-8?Q?Court=C3=A8s?= Cc: 20255@debbugs.gnu.org Ludovic Court=C3=A8s writes: > =E5=AE=8B=E6=96=87=E6=AD=A6 skribis: > >> Or better to generate a 'profile' script for each manifest, and then >> merged in shell level, so it can work out-of-the-box. How about: >> - /etc/profile: >> # configuration for the whole system goes here. >> # shouldn't refer profile paths. >> export LANG=3Den_US.utf8 >> export SSL_CERT_DIR=3D/etc/ssl/certs >> export LINUX_MODULE_DIRECTORY=3D/run/booted-system/kernel/lib/modules >> [...] >> >> source /run/current-system/profile/etc/profile >> >> if [ -f $HOME/.guix-profile/etc/profile ]; then >> source $HOME/.guix-profile/etc/profile >> fi >> >> # honor setuid-programs >> export PATH=3D/run/setuid-programs:$PATH >> >> - /run/current-system/profile/etc/profile: >> export PATH=3D/run/current-system/profile/bin:/run/current-system/pr= ofile/sbin:$PATH >> export MANPATH=3D/run/current-system/profile/share/man:$PATH >> [...] >>=20=20=20=20=20 >> - ~/.guix-profile/etc/profile: >> export PATH=3D~/.guix-profile/bin:~/.guix-profile/sbin:$PATH >> [...] > > There=E2=80=99s a further complication here: =E2=80=98profile-derivation= =E2=80=99, which builds > the profile, doesn=E2=80=99t know its user-visible name ~/.guix-profile. = It > just knows its store file name. However, we don=E2=80=99t want etc/profi= le to > read: > > export PATH=3D/gnu/store/...-profile/bin:$PATH > > because then, the user=E2=80=99s environment variables in a running sessi= on > would keep pointing to a given profile generation. Indeed. Run guix to install a package should make it available immediately. Currently, we have 'PATH=3D~/.guix-profile/bin' in profile and print hint for additional variables. (Note that when profile changes, even we build all variables with the location they going to be, a hint or re-source is still needed when the new profile bring new variables.) > > So we have to tell =E2=80=98profile-generation=E2=80=99 what the user-vis= ible name of > the profile is going to be. Attached is a very rough patch to do that. > This is not so nice because all user interfaces will now have to pass > that #:target parameter or etc/profile will be =E2=80=9Cwrong.=E2=80=9D > > Another option would be to simply run: > > eval `guix package -p ~/.guix-profile --search-paths` > > This has two downsides: > > 1. It takes ~200 ms to run on my laptop, which can maybe be > noticeable; OTOH it=E2=80=99s only for interactive shells, so maybe = that=E2=80=99s > OK. > > 2. If there=E2=80=99s a manifest format change and /etc/profile calls a= =E2=80=98guix=E2=80=99 > command that cannot handle the manifest format (because it=E2=80=99s= older > than the =E2=80=98guix=E2=80=99 used to build the profile), then it = doesn=E2=80=99t work at > all (that=E2=80=99s a bit contrived, but not completely impossible.) > > Thoughts? > How about using a shell variable as input for the location: (replace /gnu/store/xxx with $GUIX_PROFILE) # etc/profile export PATH=3D$GUIX_PROFILE/bin:$PATH export MANPATH=3D$GUIX_PROFILE/share/man:$MANPATH ... Then when 'source' it, we pass the location: (we did know where $GUIX_PROFILE is when do the 'source') # ~/.bash_profile GUIX_PROFILE=3D$HOME/.guix-profile if [ -f $GUIX_PROFILE/etc/profile ]; then . $GUIX_PROFILE/etc/profile fi # /etc/profile GUIX_PROFILE=3D/run/current-system/profile source $GUIX_PROFILE/etc/profile