l...@gnu.org (Ludovic Courtès) skribis: > 宋文武 <iyzs...@gmail.com> skribis: > >>> [...] >>>> >>>> The idea to generate profile from search-paths is not new, >>>> I heard it from you IIRC. >>>> I think it's the time to do it. >>> >>> Agreed, the plan makes sense and I think we have all the bits. >>> >>> A related question is whether to encode search path environment >>> variables into the manifest (currently they are “guessed” by looking at >>> same-named packages; see (guix build package).) I think that would >>> probably simplify things and make it easier to share this environment >>> variable code. >>> >>> Thoughts? >> I see, currently search-paths depends on the packages recipes. If we >> update the related scheme code, then search-paths got updated, even we >> didn't touch packages in profile at all. It's a little confusing. >> So I think we should encode the search-paths for each package in >> manifest. > > Done in dedb17a. > > That will make it easier to generate environment variable settings.
Here’s the patch that does that, to try on b2a7223 or later. Could you comment and give it a try? My main concern was the latency introduced at log-in shells, but it’s OK, at least on my i5+SSD laptop. --8<---------------cut here---------------start------------->8--- $ time guix package -p ~/.guix-profile -p /run/current-system/profile --search-paths > /dev/null real 0m0.290s user 0m0.372s sys 0m0.028s $ guix package -I | wc -l 215 $ guix package -p /run/current-system/profile -I | wc -l 43 --8<---------------cut here---------------end--------------->8--- I’ll push it soon if there are no objections. TIA! Ludo’.
diff --git a/gnu/system.scm b/gnu/system.scm index 2755d85..7d1d33e 100644 --- a/gnu/system.scm +++ b/gnu/system.scm @@ -429,35 +429,49 @@ export SSL_CERT_DIR=/etc/ssl/certs export SSL_CERT_FILE=\"$SSL_CERT_DIR/ca-certificates.crt\" export GIT_SSL_CAINFO=\"$SSL_CERT_FILE\" -# Crucial variables that could be missing in the profiles' 'etc/profile' -# because they would require combining both profiles. -# FIXME: See <http://bugs.gnu.org/20255>. -export MANPATH=$HOME/.guix-profile/share/man:/run/current-system/profile/share/man -export INFOPATH=$HOME/.guix-profile/share/info:/run/current-system/profile/share/info +# Search paths for GLib schemas, GTK+ icons, and so on. export XDG_DATA_DIRS=$HOME/.guix-profile/share:/run/current-system/profile/share export XDG_CONFIG_DIRS=$HOME/.guix-profile/etc/xdg:/run/current-system/profile/etc/xdg # Ignore the default value of 'PATH'. unset PATH -# Load the system profile's settings. +if [ -x /run/current-system/profile/bin/guix ] +then + # Crucial variables such as 'MANPATH' or 'INFOPATH' may be missing from the + # profiles' individual 'etc/profile'. Thus, combine both profiles when + # computing the search paths. + # + # This may take a few hundred milliseconds, but it's OK because this is + # performed for log-in shells only. + eval `/run/current-system/profile/bin/guix package \\ + -p /run/current-system/profile \\ + -p \"$HOME/.guix-profile\" --search-paths` +else + # In the unlikely case that Guix is not in the global profile, + # fall back to the simpler, yet less accurate method (see + # <http://bugs.gnu.org/20255>.) GUIX_PROFILE=/run/current-system/profile \\ . /run/current-system/profile/etc/profile -# Prepend setuid programs. -export PATH=/run/setuid-programs:$PATH - if [ -f \"$HOME/.guix-profile/etc/profile\" ] then # Load the user profile's settings. GUIX_PROFILE=\"$HOME/.guix-profile\" \\ . \"$HOME/.guix-profile/etc/profile\" -else + fi +fi + +if [ ! -f \"$HOME/.guix-profile\" ] +then # At least define this one so that basic things just work # when the user installs their first package. export PATH=\"$HOME/.guix-profile/bin:$PATH\" fi +# Prepend setuid programs. +export PATH=/run/setuid-programs:$PATH + # Append the directory of 'site-start.el' to the search path. export EMACSLOADPATH=:/etc/emacs