Subject: [PATCH 1/4] home: shells: Merge search-paths of multiple profiles.

From: [email-masked]
Date: Wed, 17 May 2023 22:04:08 +0800

From: 宋文武 <[email-masked]>

This is a followup to 40310efde9b4a4f2cf98081d6cd10f843685ebb6.

* gnu/home/services.scm (environment-variables->setup-environment-script):
Merge search-paths from multiple profiles via "guix package".
* gnu/home/services/shells.scm (zsh-file-zprofile, add-bash-configuration):
Adjust comments.
---
 gnu/home/services.scm        | 14 ++++++++++----
 gnu/home/services/shells.scm |  6 ++----
 2 files changed, 12 insertions(+), 8 deletions(-)

diff --git a/gnu/home/services.scm b/gnu/home/services.scm
index b17a34d19d..3a061cf310 100644
--- a/gnu/home/services.scm
+++ b/gnu/home/services.scm
@@ -260,11 +260,17 @@ (define (environment-variables->setup-environment-script vars)
                            (lambda (port)
                              (set-port-encoding! port "UTF-8")
                              (display "\
-HOME_ENVIRONMENT=$HOME/.guix-home
-GUIX_PROFILE=\"$HOME_ENVIRONMENT/profile\"
-PROFILE_FILE=\"$HOME_ENVIRONMENT/profile/etc/profile\"
-[ -f $PROFILE_FILE ] && . $PROFILE_FILE
+# Merge search-paths from multiple profiles, the order matters.
+eval \"$(guix package --search-paths \\
+-p $HOME/.config/guix/current \\
+-p $HOME/.guix-home/profile \\
+-p $HOME/.guix-profile \\
+-p /run/current-system/profile)\"
+
+# Prepend setuid programs.
+export PATH=/run/setuid-programs:$PATH
 
+HOME_ENVIRONMENT=$HOME/.guix-home
 case $XDG_DATA_DIRS in
   *$HOME_ENVIRONMENT/profile/share*) ;;
   *) export XDG_DATA_DIRS=$HOME_ENVIRONMENT/profile/share:$XDG_DATA_DIRS ;;
diff --git a/gnu/home/services/shells.scm b/gnu/home/services/shells.scm
index f05f2221d6..7c8908083e 100644
--- a/gnu/home/services/shells.scm
+++ b/gnu/home/services/shells.scm
@@ -185,9 +185,8 @@ (define (zsh-file-zprofile config)
   (mixed-text-file
    "zprofile"
    "\
-# Set up the system, user profile, and related variables.
+# Set up environment variables of profiles.
 source /etc/profile
-# Set up the home environment profile.
 source ~/.profile
 
 # It's only necessary if zsh is a login shell, otherwise profiles will
@@ -399,9 +398,8 @@ (define (add-bash-configuration config)
       ,(mixed-text-file
         "bash_profile"
         "\
-# Set up the system, user profile, and related variables.
+# Set up environment variables of profiles.
 # /etc/profile will be sourced by bash automatically
-# Set up the home environment profile.
 if [ -f ~/.profile ]; then source ~/.profile; fi
 
 # Honor per-interactive-shell startup file

base-commit: cf82526ac400fe953ddfbf9d7458d62ea4871d10
-- 
2.40.1