GNU bug report logs - #77035
[PATCH 0/2] home: setup-environment: Avoid prepending duplicated PATH.

Previous Next

Package: guix-patches;

Reported by: Hilton Chain <hako <at> ultrarare.space>

Date: Sat, 15 Mar 2025 13:24:02 UTC

Severity: normal

Tags: patch

Merged with 77522, 77523, 77524, 77525, 77526, 77527, 77528

Full log


View this message in rfc822 format

From: Hilton Chain <hako <at> ultrarare.space>
To: 77035 <at> debbugs.gnu.org
Cc: Hilton Chain <hako <at> ultrarare.space>, Hilton Chain <hako <at> ultrarare.space>, Ludovic Courtès <ludo <at> gnu.org>
Subject: [bug#77035] [PATCH v3 5/5] guix-install.sh: Set up all default profiles in one iteration.
Date: Tue,  1 Apr 2025 23:02:48 +0800
* etc/guix-install.sh (sys_create_init_profile): Merge settings into one
iteration.
Set up extra environment variables for Guix Home.

Change-Id: Ia443b78a5ba656b7d03e1abbba53c4bf1240e338
---
 etc/guix-install.sh | 71 ++++++++++++++++++++++++---------------------
 1 file changed, 38 insertions(+), 33 deletions(-)

diff --git a/etc/guix-install.sh b/etc/guix-install.sh
index b5d833cd64..5fd9e4690d 100755
--- a/etc/guix-install.sh
+++ b/etc/guix-install.sh
@@ -749,47 +749,52 @@ 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"
-
-# User's default profile, if it exists
-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.
+# Set up environment for all default profiles.
+for GUIX_PROFILE in "$HOME/.guix-home/profile" \
+                    "$HOME/.guix-profile" \
+                    "$HOME/.config/guix/current"
+do
+  if [ -f "$GUIX_PROFILE/etc/profile" ]; then
+    . "$GUIX_PROFILE/etc/profile"
+  fi
+  # See info '(guix) Application Setup'.
+  case $GUIX_LOCPATH in
+    *GUIX_PROFILE/lib/locale*) ;;
+    *) export GUIX_LOCPATH="$GUIX_PROFILE/lib/locale${GUIX_LOCPATH:+:}$GUIX_LOCPATH" ;;
+  esac
+  # Make basic things just work when the user installs their first package.
+  case $PATH in
+    *$GUIX_PROFILE/bin*) ;;
+    *) export PATH="$GUIX_PROFILE/bin${PATH:+:}$PATH" ;;
+  esac
+  # 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.
   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"
+    *) 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'.
+  # Expose 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
+done
 
-# Clean up after ourselves.
-unset GUIX_PROFILE
+# Set up extra environment variables for Guix Home.
+HOME_ENVIRONMENT=$HOME/.guix-home
+[ -f "$HOME_ENVIRONMENT/setup-environment" ] && . "$HOME_ENVIRONMENT/setup-environment"
+unset HOME_ENVIRONMENT
 EOF
 }
 
-- 
2.49.0





This bug report was last modified 72 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.