Ludovic Courtès <l...@gnu.org> writes: > 宋文武 <iyzs...@gmail.com> 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=en_US.utf8 >> export SSL_CERT_DIR=/etc/ssl/certs >> export LINUX_MODULE_DIRECTORY=/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=/run/setuid-programs:$PATH >> >> - /run/current-system/profile/etc/profile: >> export >> PATH=/run/current-system/profile/bin:/run/current-system/profile/sbin:$PATH >> export MANPATH=/run/current-system/profile/share/man:$PATH >> [...] >> >> - ~/.guix-profile/etc/profile: >> export PATH=~/.guix-profile/bin:~/.guix-profile/sbin:$PATH >> [...] > > There’s a further complication here: ‘profile-derivation’, which builds > the profile, doesn’t know its user-visible name ~/.guix-profile. It > just knows its store file name. However, we don’t want etc/profile to > read: > > export PATH=/gnu/store/...-profile/bin:$PATH > > because then, the user’s environment variables in a running session > would keep pointing to a given profile generation. Indeed. Run guix to install a package should make it available immediately. Currently, we have 'PATH=~/.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 ‘profile-generation’ what the user-visible 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 “wrong.” > > 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’s only for interactive shells, so maybe that’s > OK. > > 2. If there’s a manifest format change and /etc/profile calls a ‘guix’ > command that cannot handle the manifest format (because it’s older > than the ‘guix’ used to build the profile), then it doesn’t work at > all (that’s 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=$GUIX_PROFILE/bin:$PATH export MANPATH=$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=$HOME/.guix-profile if [ -f $GUIX_PROFILE/etc/profile ]; then . $GUIX_PROFILE/etc/profile fi # /etc/profile GUIX_PROFILE=/run/current-system/profile source $GUIX_PROFILE/etc/profile