From f9789e9bc6aff0ddd7b72805ec4d81a740acfe44 Mon Sep 17 00:00:00 2001 From: Liam Hupfer Date: Wed, 5 Feb 2025 22:25:01 -0600 Subject: [PATCH] guix-install.sh: Improve Guix profile sourcing. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Make both profiles use GUIX_PROFILE and reorder some code so each profile is handled in one contiguous block. The user’s profile now takes precedence over the ‘guix pull’ profile on INFOPATH. If the user already has an info reader in their Guix profile, don’t add a duplicate entry to INFOPATH. If the user doesn’t have an imperative ~/.guix-profile (i.e. they manage software with Guix Home and ‘guix shell’), don’t add an unnecessary entry to INFOPATH. Clean up after ourselves by unsetting the temporary GUIX_PROFILE variable, which only needs to be set when sourcing. * etc/guix-install.sh (sys_create_init_profile): Improve Guix profile sourcing. Change-Id: Ibceb354012d23d24deeb39b1ec02790873396a6b Signed-off-by: Ludovic Courtès --- etc/guix-install.sh | 46 +++++++++++++++++++++++++++------------------ 1 file changed, 28 insertions(+), 18 deletions(-) diff --git a/etc/guix-install.sh b/etc/guix-install.sh index 8dda149edfa..9a1d898b4ba 100755 --- a/etc/guix-install.sh +++ b/etc/guix-install.sh @@ -649,31 +649,41 @@ export XDG_CONFIG_DIRS="${XDG_CONFIG_DIRS:-/etc/xdg}" export XDG_CACHE_HOME="${XDG_CACHE_HOME:-$HOME/.cache}" # no default for XDG_RUNTIME_DIR (depends on foreign distro for semantics) -# _GUIX_PROFILE: `guix pull` profile -_GUIX_PROFILE="$HOME/.config/guix/current" -export PATH="$_GUIX_PROFILE/bin${PATH:+:}$PATH" +# `guix pull` profile +GUIX_PROFILE="$HOME/.config/guix/current" +export PATH="$GUIX_PROFILE/bin${PATH:+:}$PATH" +# Add to INFOPATH so the latest Guix documentation is available to info +# readers. When INFOPATH is unset, add a trailing colon so that Emacs searches +# 'Info-default-directory-list'. +export INFOPATH="$GUIX_PROFILE/share/info:$INFOPATH" +# Expose the latest Guix modules to Guile so guix shell and repls spawned by +# e.g. Geiser work out of the box. +export GUILE_LOAD_PATH="$GUIX_PROFILE/share/guile/site/3.0${GUILE_LOAD_PATH:+:}$GUILE_LOAD_PATH" +export GUILE_LOAD_COMPILED_PATH="$GUIX_PROFILE/lib/guile/3.0/site-ccache${GUILE_LOAD_COMPILED_PATH:+:}$GUILE_LOAD_COMPILED_PATH" -# GUIX_PROFILE: User's default profile and home profile +# User's default profile, if it exists GUIX_PROFILE="$HOME/.guix-profile" -[ -f "$GUIX_PROFILE/etc/profile" ] && . "$GUIX_PROFILE/etc/profile" -[ -L "$GUIX_PROFILE" ] && \ -GUIX_LOCPATH="$GUIX_PROFILE/lib/locale${GUIX_LOCPATH:+:}$GUIX_LOCPATH" +if [ -L "$GUIX_PROFILE" ]; then + . "$GUIX_PROFILE/etc/profile" -# Export INFOPATH so that the updated info pages can be found -# and read by both /usr/bin/info and/or $GUIX_PROFILE/bin/info -# When INFOPATH is unset, add a trailing colon so that Emacs -# searches 'Info-default-directory-list'. -export INFOPATH="$_GUIX_PROFILE/share/info:$GUIX_PROFILE/share/info:$INFOPATH" + # see info '(guix) Application Setup' + export GUIX_LOCPATH="$GUIX_PROFILE/lib/locale${GUIX_LOCPATH:+:}$GUIX_LOCPATH" + + # INFOPATH may be handled by $GUIX_PROFILE/etc/profile if the user installs + # an info reader via Guix. If the user doesn’t, explicitly add to INFOPATH + # so documentation for software from ‘guix install’ is available to the + # system info reader. + case $INFOPATH in + *$GUIX_PROFILE/share/info*) ;; + *) export INFOPATH="$GUIX_PROFILE/share/info:$INFOPATH" ;; + esac +fi # NOTE: Guix Home handles its own profile initialization in ~/.profile. See # info '(guix) Configuring the Shell'. -export GUIX_LOCPATH - -# Make Guix modules available -export GUILE_LOAD_PATH="$_GUIX_PROFILE/share/guile/site/3.0${GUILE_LOAD_PATH:+:}$GUILE_LOAD_PATH" -export GUILE_LOAD_COMPILED_PATH="$_GUIX_PROFILE/lib/guile/3.0/site-ccache${GUILE_LOAD_COMPILED_PATH:+:}$GUILE_LOAD_COMPILED_PATH" - +# Clean up after ourselves. +unset GUIX_PROFILE EOF }