[bug#77035,v2,3/3] guix-install.sh: /etc/profile.d/zzz-guix.sh: Handle Guix Home profile.

Message ID 043b31de365ae667a9d7d5588f228b94eb27e267.1743438266.git.hako@ultrarare.space
State New
Headers
Series system: /etc/profile: Take care of all default profiles. |

Commit Message

Hilton Chain March 31, 2025, 4:25 p.m. UTC
  * etc/guix-install.sh (sys_create_init_profile): Handle Guix Home profile.
Arrange so that imperative profiles order first.

Change-Id: I60057c071d1d29f7930e027720f6f86a0c6b4254
---
 etc/guix-install.sh | 86 +++++++++++++++++++++++++++------------------
 1 file changed, 52 insertions(+), 34 deletions(-)
  

Patch

diff --git a/etc/guix-install.sh b/etc/guix-install.sh
index b5d833cd64..2010dab4d0 100755
--- a/etc/guix-install.sh
+++ b/etc/guix-install.sh
@@ -749,47 +749,65 @@  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 pull` profile
-GUIX_PROFILE="$HOME/.config/guix/current"
-export PATH="$GUIX_PROFILE/bin${PATH:+:}$PATH"
-# Add to INFOPATH and MANPATH so the latest Guix documentation is available to
-# info and man readers.  When INFOPATH is unset, add a trailing colon so Emacs
-# searches 'Info-default-directory-list'.  When MANPATH is unset, add a
-# trailing colon so the system default search path is used.
-export INFOPATH="$GUIX_PROFILE/share/info:$INFOPATH"
-export MANPATH="$GUIX_PROFILE/share/man:$MANPATH"
-# 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"
+# Merge search paths and set up environment for all default profiles.
+eval "$(guix package \
+  --search-paths=prefix \
+  --profile="$HOME/.config/guix/current" \
+  --profile="$HOME/.guix-profile" \
+  --profile="$HOME/.guix-home/profile")"
+
+for profile in "$HOME/.guix-home/profile" \
+               "$HOME/.guix-profile" \
+               "$HOME/.config/guix/current"
+do
+  GUIX_PROFILE="$profile"
+  if [ -L "$GUIX_PROFILE" ]; then
+    # Documentation search paths may be handled by $GUIX_PROFILE/etc/profile if
+    # the user installs info and man readers via Guix.  If the user doesn’t,
+    # explicitly add to them so documentation for software from ‘guix install’
+    # is available to the system info and man readers.  When INFOPATH is unset,
+    # add a trailing colon so Emacs searches 'Info-default-directory-list'.
+    # When MANPATH is unset, add a trailing colon so the system default search
+    # path is used.
+    case $INFOPATH in
+      *$GUIX_PROFILE/share/info*) ;;
+      *) export INFOPATH="$GUIX_PROFILE/share/info:$INFOPATH" ;;
+    esac
+    case $MANPATH in
+      *$GUIX_PROFILE/share/man*) ;;
+      *) export MANPATH="$GUIX_PROFILE/share/man:$MANPATH"
+    esac
+  fi
+done
 
-# User's default profile, if it exists
+# See info '(guix) Application Setup'.
 GUIX_PROFILE="$HOME/.guix-profile"
 if [ -L "$GUIX_PROFILE" ]; then
-  . "$GUIX_PROFILE/etc/profile"
-
-  # see info '(guix) Application Setup'
   export GUIX_LOCPATH="$GUIX_PROFILE/lib/locale${GUIX_LOCPATH:+:}$GUIX_LOCPATH"
-
-  # Documentation search paths may be handled by $GUIX_PROFILE/etc/profile if
-  # the user installs info and man readers via Guix.  If the user doesn’t,
-  # explicitly add to them so documentation for software from ‘guix install’
-  # is available to the system info and man readers.
-  case $INFOPATH in
-    *$GUIX_PROFILE/share/info*) ;;
-    *) export INFOPATH="$GUIX_PROFILE/share/info:$INFOPATH" ;;
-  esac
-  case $MANPATH in
-    *$GUIX_PROFILE/share/man*) ;;
-    *) export MANPATH="$GUIX_PROFILE/share/man:$MANPATH"
-  esac
 fi
 
-# NOTE: Guix Home handles its own profile initialization in ~/.profile. See
-# info '(guix) Configuring the Shell'.
-
-# Clean up after ourselves.
+# Make ‘guix pull’ profile work out of the box.
+GUIX_PROFILE="$HOME/.config/guix/current"
+case $PATH in
+  *$GUIX_PROFILE/bin*) ;;
+  *) export PATH="$GUIX_PROFILE/bin${PATH:+:}$PATH" ;;
+esac
+# Expose the latest Guix modules to Guile so guix shell and repls spawned by
+# e.g. Geiser work out of the box.
+case $GUILE_LOAD_PATH in
+  *$GUIX_PROFILE/share/guile/site/3.0*) ;;
+  *) export GUILE_LOAD_PATH="$GUIX_PROFILE/share/guile/site/3.0${GUILE_LOAD_PATH:+:}$GUILE_LOAD_PATH" ;;
+esac
+case $GUILE_LOAD_COMPILED_PATH in
+  *$GUIX_PROFILE/lib/guile/3.0/site-ccache*) ;;
+  *) export GUILE_LOAD_COMPILED_PATH="$GUIX_PROFILE/lib/guile/3.0/site-ccache${GUILE_LOAD_COMPILED_PATH:+:}$GUILE_LOAD_COMPILED_PATH" ;;
+esac
 unset GUIX_PROFILE
+
+# Set up extra environment variables for Guix Home.
+HOME_ENVIRONMENT="$HOME/.guix-home"
+[ -L "$HOME_ENVIRONMENT" ] && . "$HOME_ENVIRONMENT/setup-environment"
+unset HOME_ENVIRONMENT
 EOF
 }