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

To reply to this bug, email your comments to 77035 AT debbugs.gnu.org.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to andrew <at> trop.in, janneke <at> gnu.org, ludo <at> gnu.org, tanguy <at> bioneland.org, guix-patches <at> gnu.org:
bug#77035; Package guix-patches. (Sat, 15 Mar 2025 13:24:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Hilton Chain <hako <at> ultrarare.space>:
New bug report received and forwarded. Copy sent to andrew <at> trop.in, janneke <at> gnu.org, ludo <at> gnu.org, tanguy <at> bioneland.org, guix-patches <at> gnu.org. (Sat, 15 Mar 2025 13:24:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Hilton Chain <hako <at> ultrarare.space>
To: guix-patches <at> gnu.org
Cc: Hilton Chain <hako <at> ultrarare.space>
Subject: [PATCH 0/2] home: setup-environment: Avoid prepending duplicated PATH.
Date: Sat, 15 Mar 2025 21:23:22 +0800
Hi Guix,

Here's a patch series following my comments in https://issues.guix.gnu.org/63009#10,

Currently on a Guix System, PATH entries is in the following order:
--8<---------------cut here---------------start------------->8---
~/.guix-home/profile/bin
~/.guix-home/profile/sbin
/run/privileged/bin
~/.config/guix/current/bin
~/.guix-home/profile/bin
~/.guix-home/profile/sbin
~/.guix-profile/bin
~/.guix-profile/sbin
/run/current-system/profile/bin
/run/current-system/profile/sbin
--8<---------------cut here---------------end--------------->8---

With this change, it will be changed to:
--8<---------------cut here---------------start------------->8---
/run/privileged/bin
~/.config/guix/current/bin
~/.guix-profile/bin
~/.guix-profile/sbin
~/.guix-home/profile/bin
~/.guix-home/profile/sbin
/run/current-system/profile/bin
/run/current-system/profile/sbin
--8<---------------cut here---------------end--------------->8---

I haven't changed guix-install.sh yet, so the following remains on foregin
distros:
--8<---------------cut here---------------start------------->8---
~/.guix-home/profile/bin
~/.guix-home/profile/sbin
~/.guix-profile/bin
~/.guix-profile/sbin
--8<---------------cut here---------------end--------------->8---

If you agree with [PATCH 1/2], I'll change guix-install.sh too.

Thanks

Hilton Chain (2):
  gnu: system: Order imperative profiles first in etc/profile.
  home: setup-environment: Avoid prepending duplicated PATH.

 gnu/home/services.scm | 14 +++++++++++++-
 gnu/system.scm        |  6 +++---
 2 files changed, 16 insertions(+), 4 deletions(-)


base-commit: 3cc51c3e7447ab4f590d530fa66f65b6152ab109
--
2.48.1




Information forwarded to guix-patches <at> gnu.org:
bug#77035; Package guix-patches. (Sat, 15 Mar 2025 13:26:02 GMT) Full text and rfc822 format available.

Message #8 received at 77035 <at> debbugs.gnu.org (full text, mbox):

From: Hilton Chain <hako <at> ultrarare.space>
To: 77035 <at> debbugs.gnu.org
Cc: Hilton Chain <hako <at> ultrarare.space>
Subject: [PATCH 1/2] gnu: system: Order imperative profiles first in
 etc/profile.
Date: Sat, 15 Mar 2025 21:24:45 +0800
* gnu/system.scm (operating-system-etc-service): Swap profile order for
guix-package and guix-home.

Change-Id: Id32568772f4944c22ad830e7416a97d6b0adb66c
---
 gnu/system.scm | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/gnu/system.scm b/gnu/system.scm
index 0d98e5a036..6c4b4efc3a 100644
--- a/gnu/system.scm
+++ b/gnu/system.scm
@@ -1090,9 +1090,9 @@ (define* (operating-system-etc-service os)
 fi
 
 # Arrange so that ~/.config/guix/current comes first,
-# and guix-home comes before guix-profile.
-for profile in \"$HOME/.guix-profile\"        \\
-               \"$HOME/.guix-home/profile\"   \\
+# and guix-profile comes before guix-home.
+for profile in \"$HOME/.guix-home/profile\"   \\
+               \"$HOME/.guix-profile\"        \\
                \"$HOME/.config/guix/current\"
 do
   if [ -f \"$profile/etc/profile\" ]
-- 
2.48.1





Information forwarded to andrew <at> trop.in, janneke <at> gnu.org, ludo <at> gnu.org, tanguy <at> bioneland.org, guix-patches <at> gnu.org:
bug#77035; Package guix-patches. (Sat, 15 Mar 2025 13:26:02 GMT) Full text and rfc822 format available.

Message #11 received at 77035 <at> debbugs.gnu.org (full text, mbox):

From: Hilton Chain <hako <at> ultrarare.space>
To: 77035 <at> debbugs.gnu.org
Cc: Hilton Chain <hako <at> ultrarare.space>
Subject: [PATCH 2/2] home: setup-environment: Avoid prepending duplicated PATH.
Date: Sat, 15 Mar 2025 21:24:46 +0800
This makes best effort to order /run/privileged/bin first.

* gnu/home/services.scm (environment-variables->setup-environment-script):
Avoid prepending duplicated PATH.

Change-Id: I580fbbf4786b56b903c1a4d6eb5fa92a70e331b4
---
 gnu/home/services.scm | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/gnu/home/services.scm b/gnu/home/services.scm
index 85a43f80ca..9855e26d97 100644
--- a/gnu/home/services.scm
+++ b/gnu/home/services.scm
@@ -278,9 +278,21 @@ (define (environment-variables->setup-environment-script vars)
 # NOTE: Set HOME_ENVIRONMENT before sourcing (home-shell-profile-service-type ensures
 # ~/.profile does)
 GUIX_PROFILE=\"$HOME_ENVIRONMENT/profile\"
+
+# Check if PATH for home profile was already set by /etc/profile.
+case $PATH in
+  *$GUIX_PROFILE/bin*) OLD_PATH=$PATH ;;
+esac
+
 PROFILE_FILE=\"$GUIX_PROFILE/etc/profile\"
 [ -f $PROFILE_FILE ] && . $PROFILE_FILE
 
+# Don't modify PATH if it was already set for home profile.
+# This ensures /run/privileged/bin to be ordered first.
+if [ -n \"$OLD_PATH\" ]; then
+  export PATH=$OLD_PATH
+fi
+
 case $GUIX_LOCPATH in
   *$GUIX_PROFILE/lib/locale*) ;;
   *) export GUIX_LOCPATH=$GUIX_PROFILE/lib/locale:$GUIX_LOCPATH ;;
@@ -307,7 +319,7 @@ (define (environment-variables->setup-environment-script vars)
 esac
 
 # Keep the shell environment clean.
-unset GUIX_PROFILE PROFILE_FILE
+unset OLD_PATH GUIX_PROFILE PROFILE_FILE
 
 " port)
                              (display
-- 
2.48.1





Information forwarded to guix-patches <at> gnu.org:
bug#77035; Package guix-patches. (Wed, 19 Mar 2025 10:31:01 GMT) Full text and rfc822 format available.

Message #14 received at 77035 <at> debbugs.gnu.org (full text, mbox):

From: Ludovic Courtès <ludo <at> gnu.org>
To: Hilton Chain <hako <at> ultrarare.space>
Cc: 77035 <at> debbugs.gnu.org, Janneke Nieuwenhuizen <janneke <at> gnu.org>,
 Tanguy Le Carrour <tanguy <at> bioneland.org>, Andrew Tropin <andrew <at> trop.in>
Subject: Re: [bug#77035] [PATCH 0/2] home: setup-environment: Avoid
 prepending duplicated PATH.
Date: Wed, 19 Mar 2025 11:29:56 +0100
Hi Hilton,

Hilton Chain <hako <at> ultrarare.space> skribis:

> With this change, it will be changed to:
>
> /run/privileged/bin
> ~/.config/guix/current/bin
> ~/.guix-profile/bin
> ~/.guix-profile/sbin
> ~/.guix-home/profile/bin
> ~/.guix-home/profile/sbin
> /run/current-system/profile/bin
> /run/current-system/profile/sbin
>
>
> I haven't changed guix-install.sh yet, so the following remains on foregin
> distros:
>
> ~/.guix-home/profile/bin
> ~/.guix-home/profile/sbin
> ~/.guix-profile/bin
> ~/.guix-profile/sbin
>
> If you agree with [PATCH 1/2], I'll change guix-install.sh too.

This LGTM.  I let you send the ‘guix-install.sh’ change and then push it
all at once, sounds good?

Thanks,
Ludo’.




Information forwarded to hako <at> ultrarare.space, ludo <at> gnu.org, guix-patches <at> gnu.org:
bug#77035; Package guix-patches. (Mon, 31 Mar 2025 16:27:02 GMT) Full text and rfc822 format available.

Message #17 received at 77035 <at> debbugs.gnu.org (full text, mbox):

From: Hilton Chain <hako <at> ultrarare.space>
To: 77035 <at> debbugs.gnu.org
Cc: Hilton Chain <hako <at> ultrarare.space>
Subject: [PATCH v2 0/3] system: /etc/profile: Take care of all default
 profiles.
Date: Tue,  1 Apr 2025 00:25:55 +0800
I ended up with a bigger change, so sending v2 for review ;)

Note that I haven't tested the guix-install.sh change yet.

Hilton Chain (3):
  system: /etc/profile: Take care of all default profiles.
  home: setup-environment: Skip if already initialized.
  guix-install.sh: /etc/profile.d/zzz-guix.sh: Handle Guix Home profile.

 etc/guix-install.sh          |  86 +++++++++++--------
 gnu/home/services.scm        |  18 ++--
 gnu/home/services/shells.scm |  10 ++-
 gnu/system.scm               | 155 +++++++++++++++++++++++------------
 gnu/system/shadow.scm        |  10 ---
 5 files changed, 174 insertions(+), 105 deletions(-)


base-commit: 77d5eb4c16984e430b377e0b5f1551fbda171ec6
--
2.49.0




Information forwarded to hako <at> ultrarare.space, ludo <at> gnu.org, guix-patches <at> gnu.org:
bug#77035; Package guix-patches. (Mon, 31 Mar 2025 16:27:03 GMT) Full text and rfc822 format available.

Message #20 received at 77035 <at> debbugs.gnu.org (full text, mbox):

From: Hilton Chain <hako <at> ultrarare.space>
To: 77035 <at> debbugs.gnu.org
Cc: Hilton Chain <hako <at> ultrarare.space>
Subject: [PATCH v2 1/3] system: /etc/profile: Take care of all default
 profiles.
Date: Tue,  1 Apr 2025 00:25:56 +0800
* gnu/system.scm (operating-system-etc-service)[/etc/profile]: Merge search
paths.
Take care of all default profiles.
Address some issues reported by ‘shellcheck’.
* gnu/system/shadow.scm (%default-bash-profile): Remove duplicated exports.

Change-Id: I0e14d7c0266742e0abf07779e501de0e257c1329
---
 gnu/system.scm        | 155 ++++++++++++++++++++++++++++--------------
 gnu/system/shadow.scm |  10 ---
 2 files changed, 104 insertions(+), 61 deletions(-)

diff --git a/gnu/system.scm b/gnu/system.scm
index 0d98e5a036..e05f5938bc 100644
--- a/gnu/system.scm
+++ b/gnu/system.scm
@@ -1060,71 +1060,124 @@ (define* (operating-system-etc-service os)
         ;; Startup file for POSIX-compliant login shells, which set system-wide
         ;; environment variables.
         (profile    (mixed-text-file "profile"  "\
-# 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
-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
-
-# Make sure libXcursor finds cursors installed into user or system profiles.  See <http://bugs.gnu.org/24445>
-export XCURSOR_PATH=$HOME/.icons:$HOME/.guix-profile/share/icons:/run/current-system/profile/share/icons
+# Set the umask, notably for users logging in via 'lsh'.
+# See <http://bugs.gnu.org/22650>.
+umask 022
 
 # Ignore the default value of 'PATH'.
 unset PATH
 
-# Load the system profile's settings.
-GUIX_PROFILE=/run/current-system/profile ; \\
-. /run/current-system/profile/etc/profile
-
 # Since 'lshd' does not use pam_env, /etc/environment must be explicitly
 # loaded when someone logs in via SSH.  See <http://bugs.gnu.org/22175>.
-# We need 'PATH' to be defined here, for 'cat' and 'cut'.  Do this before
-# reading the user's 'etc/profile' to allow variables to be overridden.
-if [ -f /etc/environment -a -n \"$SSH_CLIENT\" \\
-     -a -z \"$LINUX_MODULE_DIRECTORY\" ]
+# Do this before reading the user's 'etc/profile' to allow variables to be
+# overridden.
+if [ -f /etc/environment ] && [ -n \"$SSH_CLIENT\" ] &&
+     [ -z \"$LINUX_MODULE_DIRECTORY\" ]
 then
   . /etc/environment
-  export `cat /etc/environment | cut -d= -f1`
+  export \"$(/run/current-system/profile/bin/cut -d= -f1 < /etc/environment)\"
 fi
 
-# Arrange so that ~/.config/guix/current comes first,
-# and guix-home comes before guix-profile.
-for profile in \"$HOME/.guix-profile\"        \\
-               \"$HOME/.guix-home/profile\"   \\
-               \"$HOME/.config/guix/current\"
-do
-  if [ -f \"$profile/etc/profile\" ]
-  then
-    # Load the user profile's settings.
-    GUIX_PROFILE=\"$profile\" ; \\
-    . \"$profile/etc/profile\"
-  else
-    # At least define this one so that basic things just work
-    # when the user installs their first package.
-    export PATH=\"$profile/bin:$PATH\"
-  fi
-done
+# Merge search paths and set up environment for all default profiles.
+eval \"$(/run/current-system/profile/bin/guix package \\
+  --search-paths=prefix \\
+  --profile=\"$HOME/.config/guix/current\" \\
+  --profile=\"$HOME/.guix-profile\" \\
+  --profile=\"$HOME/.guix-home/profile\" \\
+  --profile=/run/current-system/profile)\"
+
+# 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
 
 # Prepend privileged programs.
-export PATH=/run/privileged/bin:$PATH
-
-# Arrange so that ~/.config/guix/current/share/info comes first.
-export INFOPATH=\"$HOME/.config/guix/current/share/info:$INFOPATH\"
-
-# Set the umask, notably for users logging in via 'lsh'.
-# See <http://bugs.gnu.org/22650>.
-umask 022
-
-# Allow Hunspell-based applications (IceCat, LibreOffice, etc.) to
-# find dictionaries.
-export DICPATH=\"$HOME/.guix-profile/share/hunspell:/run/current-system/profile/share/hunspell\"
-
+export PATH=\"/run/privileged/bin:$PATH\"
+
+# Crucial variables that could be missing in the profiles' 'etc/profile'.
+if [ -z \"$XDG_DATA_DIRS\" ]; then
+  export XDG_DATA_DIRS=\"`
+         `$HOME/.guix-profile/share:`
+         `$HOME/.guix-home/profile/share:`
+         `/run/current-system/profile/share\"
+fi
+if [ -z \"$XDG_CONFIG_DIRS\" ]; then
+  export XDG_CONFIG_DIRS=\"`
+         `$HOME/.guix-profile/etc/xdg:`
+         `$HOME/.guix-home/profile/etc/xdg:`
+         `/run/current-system/profile/etc/xdg\"
+fi
+# When MANPATH is unset, add a trailing colon so the system default search path
+# is used.
+if [ -z \"$MANPATH\" ]; then
+  export MANPATH=\"`
+         `$HOME/.guix-profile/share/man:`
+         `$HOME/.guix-home/profile/share/man:`
+         `/run/current-system/profile/share/man:\"
+fi
+# When INFOPATH is unset, add a trailing colon so Emacs searches
+# 'Info-default-directory-list'.
+if [ -z \"$INFOPATH\" ]; then
+  export INFOPATH=\"`
+         `$HOME/.config/guix/current/share/info:`
+         `$HOME/.guix-profile/share/info:`
+         `$HOME/.guix-home/profile/share/info:`
+         `/run/current-system/profile/share/info:\"
+else
+  case $INFOPATH in
+    *$HOME/.config/guix/current/share/info*) ;;
+    *) export INFOPATH=\"$HOME/.config/guix/current/share/info:$INFOPATH\" ;;
+  esac
+fi
+# Make sure libXcursor finds cursors installed into user or system profiles.
+# See <http://bugs.gnu.org/24445>
+if [ -z \"$XCURSOR_PATH\" ]; then
+  export XCURSOR_PATH=\"`
+         `$HOME/.icons:`
+         `$HOME/.guix-profile/share/icons:`
+         `$HOME/.guix-home/profile/share/icons:`
+         `/run/current-system/profile/share/icons\"
+else
+  case $XCURSOR_PATH in
+    *$HOME/.icons*) ;;
+    *) export XCURSOR_PATH=\"$HOME/.icons:$XCURSOR_PATH\" ;;
+  esac
+fi
+# Allow Hunspell-based applications (IceCat, LibreOffice, etc.) to find
+# dictionaries.
+if [ -z \"$DICPATH\" ]; then
+  export DICPATH=\"`
+         `$HOME/.guix-profile/share/hunspell:`
+         `$HOME/.guix-home/profile/share/hunspell:`
+         `/run/current-system/profile/share/hunspell\"
+fi
 # Allow GStreamer-based applications to find plugins.
-export GST_PLUGIN_PATH=\"$HOME/.guix-profile/lib/gstreamer-1.0\"
+if [ -z \"$GST_PLUGIN_PATH\" ]; then
+  export GST_PLUGIN_PATH=\"`
+         `$HOME/.guix-profile/lib/gstreamer-1.0:`
+         `$HOME/.guix-home/profile/lib/gstreamer-1.0:`
+         `/run/current-system/profile/lib/gstreamer-1.0\"
+fi
+
+# Set up extra environment variables for Guix Home.
+HOME_ENVIRONMENT=\"$HOME/.guix-home\"
+[ -L \"$HOME_ENVIRONMENT\" ] && . \"$HOME_ENVIRONMENT/setup-environment\"
+unset HOME_ENVIRONMENT
 
-if [ -n \"$BASH_VERSION\" -a -f /etc/bashrc ]
+if [ -n \"$BASH_VERSION\" ] && [ -f /etc/bashrc ]
 then
   # Load Bash-specific initialization code.
   . /etc/bashrc
diff --git a/gnu/system/shadow.scm b/gnu/system/shadow.scm
index b68a818871..cdb804da18 100644
--- a/gnu/system/shadow.scm
+++ b/gnu/system/shadow.scm
@@ -179,16 +179,6 @@ (define %default-bash-profile
 
 # Honor per-interactive-shell startup file
 if [ -f ~/.bashrc ]; then . ~/.bashrc; fi
-
-# 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
 "))
 
 (define %default-zprofile
-- 
2.49.0





Information forwarded to hako <at> ultrarare.space, ludo <at> gnu.org, andrew <at> trop.in, janneke <at> gnu.org, tanguy <at> bioneland.org, guix-patches <at> gnu.org:
bug#77035; Package guix-patches. (Mon, 31 Mar 2025 16:27:03 GMT) Full text and rfc822 format available.

Message #23 received at 77035 <at> debbugs.gnu.org (full text, mbox):

From: Hilton Chain <hako <at> ultrarare.space>
To: 77035 <at> debbugs.gnu.org
Cc: Hilton Chain <hako <at> ultrarare.space>
Subject: [PATCH v2 2/3] home: setup-environment: Skip if already initialized.
Date: Tue,  1 Apr 2025 00:25:57 +0800
* gnu/home/services.scm (environment-variables->setup-environment-script):
Skip initializing home profile if already finished.
Address some issues reported by ‘shellcheck’.
* gnu/home/services/shells.scm (add-shell-profile-file): Skip
setup-environment if already finished.
Address some issues reported by ‘shellcheck’.

Change-Id: Ife4100c6b19f61272525eebc82931c81784fe9e0
---
 gnu/home/services.scm        | 18 +++++++++++-------
 gnu/home/services/shells.scm | 10 +++++++---
 2 files changed, 18 insertions(+), 10 deletions(-)

diff --git a/gnu/home/services.scm b/gnu/home/services.scm
index 85a43f80ca..39ad31515c 100644
--- a/gnu/home/services.scm
+++ b/gnu/home/services.scm
@@ -279,31 +279,35 @@ (define (environment-variables->setup-environment-script vars)
 # ~/.profile does)
 GUIX_PROFILE=\"$HOME_ENVIRONMENT/profile\"
 PROFILE_FILE=\"$GUIX_PROFILE/etc/profile\"
-[ -f $PROFILE_FILE ] && . $PROFILE_FILE
+# Skip if already initialized.
+case $INFOPATH in
+  *$GUIX_PROFILE/share/info*) ;;
+  *) [ -f \"$PROFILE_FILE\" ] && . \"$PROFILE_FILE\" ;;
+esac
 
 case $GUIX_LOCPATH in
   *$GUIX_PROFILE/lib/locale*) ;;
-  *) export GUIX_LOCPATH=$GUIX_PROFILE/lib/locale:$GUIX_LOCPATH ;;
+  *) export GUIX_LOCPATH=\"$GUIX_PROFILE/lib/locale:$GUIX_LOCPATH\" ;;
 esac
 case $XDG_DATA_DIRS in
   *$GUIX_PROFILE/share*) ;;
-  *) export XDG_DATA_DIRS=$GUIX_PROFILE/share:$XDG_DATA_DIRS ;;
+  *) export XDG_DATA_DIRS=\"$GUIX_PROFILE/share:$XDG_DATA_DIRS\" ;;
 esac
 case $MANPATH in
   *$GUIX_PROFILE/share/man*) ;;
-  *) export MANPATH=$GUIX_PROFILE/share/man:$MANPATH
+  *) export MANPATH=\"$GUIX_PROFILE/share/man:$MANPATH\" ;;
 esac
 case $INFOPATH in
   *$GUIX_PROFILE/share/info*) ;;
-  *) export INFOPATH=$GUIX_PROFILE/share/info:$INFOPATH ;;
+  *) export INFOPATH=\"$GUIX_PROFILE/share/info:$INFOPATH\" ;;
 esac
 case $XDG_CONFIG_DIRS in
   *$GUIX_PROFILE/etc/xdg*) ;;
-  *) export XDG_CONFIG_DIRS=$GUIX_PROFILE/etc/xdg:$XDG_CONFIG_DIRS ;;
+  *) export XDG_CONFIG_DIRS=\"$GUIX_PROFILE/etc/xdg:$XDG_CONFIG_DIRS\" ;;
 esac
 case $XCURSOR_PATH in
   *$GUIX_PROFILE/share/icons*) ;;
-  *) export XCURSOR_PATH=$GUIX_PROFILE/share/icons:$XCURSOR_PATH ;;
+  *) export XCURSOR_PATH=\"$GUIX_PROFILE/share/icons:$XCURSOR_PATH\" ;;
 esac
 
 # Keep the shell environment clean.
diff --git a/gnu/home/services/shells.scm b/gnu/home/services/shells.scm
index bab5730c3d..ce61eaa4b0 100644
--- a/gnu/home/services/shells.scm
+++ b/gnu/home/services/shells.scm
@@ -87,9 +87,13 @@ (define (add-shell-profile-file config)
      ,(mixed-text-file
        "shell-profile"
        "\
-HOME_ENVIRONMENT=$HOME/.guix-home
-. $HOME_ENVIRONMENT/setup-environment
-$HOME_ENVIRONMENT/on-first-login
+HOME_ENVIRONMENT=\"$HOME/.guix-home\"
+# Skip if already sourced.
+case $GUIX_LOCPATH in
+  *$HOME_ENVIRONMENT/profile/lib/locale*) ;;
+  *) . \"$HOME_ENVIRONMENT/setup-environment\" ;;
+esac
+\"$HOME_ENVIRONMENT/on-first-login\"
 unset HOME_ENVIRONMENT\n"
        (serialize-configuration
         config
-- 
2.49.0





Information forwarded to hako <at> ultrarare.space, ludo <at> gnu.org, guix-patches <at> gnu.org:
bug#77035; Package guix-patches. (Mon, 31 Mar 2025 16:27:04 GMT) Full text and rfc822 format available.

Message #26 received at 77035 <at> debbugs.gnu.org (full text, mbox):

From: Hilton Chain <hako <at> ultrarare.space>
To: 77035 <at> debbugs.gnu.org
Cc: Hilton Chain <hako <at> ultrarare.space>
Subject: [PATCH v2 3/3] guix-install.sh: /etc/profile.d/zzz-guix.sh: Handle
 Guix Home profile.
Date: Tue,  1 Apr 2025 00:25:58 +0800
* 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(-)

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
 }
 
-- 
2.49.0





Information forwarded to guix-patches <at> gnu.org:
bug#77035; Package guix-patches. (Tue, 01 Apr 2025 12:27:03 GMT) Full text and rfc822 format available.

Message #29 received at 77035 <at> debbugs.gnu.org (full text, mbox):

From: Ludovic Courtès <ludo <at> gnu.org>
To: Hilton Chain <hako <at> ultrarare.space>
Cc: 77035 <at> debbugs.gnu.org
Subject: Re: [bug#77035] [PATCH v2 1/3] system: /etc/profile: Take care of
 all default profiles.
Date: Tue, 01 Apr 2025 14:25:59 +0200
Hi,

Hilton Chain <hako <at> ultrarare.space> skribis:

> * gnu/system.scm (operating-system-etc-service)[/etc/profile]: Merge search
> paths.
> Take care of all default profiles.
> Address some issues reported by ‘shellcheck’.
> * gnu/system/shadow.scm (%default-bash-profile): Remove duplicated exports.
>
> Change-Id: I0e14d7c0266742e0abf07779e501de0e257c1329

I’m afraid there are too many changes, mostly unrelated here, and mostly
not covered by the commit log.  :-)

Could you split it somewhat and explain?

> +# Merge search paths and set up environment for all default profiles.
> +eval \"$(/run/current-system/profile/bin/guix package \\
> +  --search-paths=prefix \\
> +  --profile=\"$HOME/.config/guix/current\" \\
> +  --profile=\"$HOME/.guix-profile\" \\
> +  --profile=\"$HOME/.guix-home/profile\" \\
> +  --profile=/run/current-system/profile)\"

FWIW, this (invoking ‘guix package’ from /etc/profile) was explicitly
rejected back then:

  https://issues.guix.gnu.org/20255#32

So at least let’s not address it in the middle of other changes.

Thanks,
Ludo’.




Information forwarded to hako <at> ultrarare.space, ludo <at> gnu.org, guix-patches <at> gnu.org:
bug#77035; Package guix-patches. (Tue, 01 Apr 2025 15:04:02 GMT) Full text and rfc822 format available.

Message #32 received at 77035 <at> debbugs.gnu.org (full text, mbox):

From: Hilton Chain <hako <at> ultrarare.space>
To: 77035 <at> debbugs.gnu.org
Cc: Hilton Chain <hako <at> ultrarare.space>
Subject: [PATCH v3 0/5] system: Rearrange /etc/profile.
Date: Tue,  1 Apr 2025 23:02:43 +0800
V2 -> V3:
* Rearrange changes.
* Avoid invoking ‘guix’ from profile.

Hilton Chain (5):
  system: /etc/profile: Set up all default profiles in one iteration.
  system: Rearrange /etc/profile.
  system: /etc/profile: Set up extra environment variables for Guix
    Home.
  system & home: profile: Address issues reported by ‘shellcheck’.
  guix-install.sh: Set up all default profiles in one iteration.

 etc/guix-install.sh          |  71 ++++++++++----------
 gnu/home/services.scm        |  22 +++++--
 gnu/home/services/shells.scm |  10 ++-
 gnu/system.scm               | 123 ++++++++++++++++++++++-------------
 gnu/system/shadow.scm        |  10 ---
 5 files changed, 137 insertions(+), 99 deletions(-)


base-commit: 295f6417025638dfcd94b5c19bfbff3c5a85e5e4
--
2.49.0




Information forwarded to hako <at> ultrarare.space, ludo <at> gnu.org, guix-patches <at> gnu.org:
bug#77035; Package guix-patches. (Tue, 01 Apr 2025 15:04:03 GMT) Full text and rfc822 format available.

Message #35 received at 77035 <at> debbugs.gnu.org (full text, mbox):

From: Hilton Chain <hako <at> ultrarare.space>
To: 77035 <at> debbugs.gnu.org
Cc: Hilton Chain <hako <at> ultrarare.space>
Subject: [PATCH v3 1/5] system: /etc/profile: Set up all default profiles in
 one iteration.
Date: Tue,  1 Apr 2025 23:02:44 +0800
* gnu/system.scm (operating-system-etc-service)[profile]: Make Guix Home paths
appear before the default user profile.
Set up Guix System profile in the iteration too.
Rename iteration variable to GUIX_PROFILE.

Change-Id: I18eac738a5dfade84da2effdd6211119c6fdd96f
---
 gnu/system.scm | 24 +++++++++---------------
 1 file changed, 9 insertions(+), 15 deletions(-)

diff --git a/gnu/system.scm b/gnu/system.scm
index 0d98e5a036..c166222854 100644
--- a/gnu/system.scm
+++ b/gnu/system.scm
@@ -1074,10 +1074,6 @@ (define* (operating-system-etc-service os)
 # Ignore the default value of 'PATH'.
 unset PATH
 
-# Load the system profile's settings.
-GUIX_PROFILE=/run/current-system/profile ; \\
-. /run/current-system/profile/etc/profile
-
 # Since 'lshd' does not use pam_env, /etc/environment must be explicitly
 # loaded when someone logs in via SSH.  See <http://bugs.gnu.org/22175>.
 # We need 'PATH' to be defined here, for 'cat' and 'cut'.  Do this before
@@ -1086,24 +1082,22 @@ (define* (operating-system-etc-service os)
      -a -z \"$LINUX_MODULE_DIRECTORY\" ]
 then
   . /etc/environment
-  export `cat /etc/environment | cut -d= -f1`
+  export `/run/current-system/profile/bin/cut -d= -f1 < /etc/environment`
 fi
 
-# Arrange so that ~/.config/guix/current comes first,
-# and guix-home comes before guix-profile.
-for profile in \"$HOME/.guix-profile\"        \\
-               \"$HOME/.guix-home/profile\"   \\
-               \"$HOME/.config/guix/current\"
+# Set up environment for all default profiles.
+for GUIX_PROFILE in \"/run/current-system/profile\" \\
+                    \"$HOME/.guix-home/profile\"   \\
+                    \"$HOME/.guix-profile\"        \\
+                    \"$HOME/.config/guix/current\"
 do
-  if [ -f \"$profile/etc/profile\" ]
+  if [ -f \"$GUIX_PROFILE/etc/profile\" ]
   then
-    # Load the user profile's settings.
-    GUIX_PROFILE=\"$profile\" ; \\
-    . \"$profile/etc/profile\"
+    . \"$GUIX_PROFILE/etc/profile\"
   else
     # At least define this one so that basic things just work
     # when the user installs their first package.
-    export PATH=\"$profile/bin:$PATH\"
+    export PATH=\"$GUIX_PROFILE/bin:$PATH\"
   fi
 done
 
-- 
2.49.0





Information forwarded to hako <at> ultrarare.space, ludo <at> gnu.org, guix-patches <at> gnu.org:
bug#77035; Package guix-patches. (Tue, 01 Apr 2025 15:04:03 GMT) Full text and rfc822 format available.

Message #38 received at 77035 <at> debbugs.gnu.org (full text, mbox):

From: Hilton Chain <hako <at> ultrarare.space>
To: 77035 <at> debbugs.gnu.org
Cc: Hilton Chain <hako <at> ultrarare.space>
Subject: [PATCH v3 2/5] system: Rearrange /etc/profile.
Date: Tue,  1 Apr 2025 23:02:45 +0800
* gnu/system.scm (operating-system-etc-service)[profile]: Set umask first.
Move extra environment variables setup into the iteration.
Add $GUILE_LOAD_PATH and $GUILE_LOAD_COMPILED_PATH.
* gnu/system/shadow.scm (%default-bash-profile): Remove duplicated exports.

Change-Id: I42ae153b9cd47ca24448fa18ce7f80a5e5c06621
---
 gnu/system.scm        | 90 +++++++++++++++++++++++++++++--------------
 gnu/system/shadow.scm | 10 -----
 2 files changed, 61 insertions(+), 39 deletions(-)

diff --git a/gnu/system.scm b/gnu/system.scm
index c166222854..9fb4275b45 100644
--- a/gnu/system.scm
+++ b/gnu/system.scm
@@ -1060,16 +1060,9 @@ (define* (operating-system-etc-service os)
         ;; Startup file for POSIX-compliant login shells, which set system-wide
         ;; environment variables.
         (profile    (mixed-text-file "profile"  "\
-# 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
-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
-
-# Make sure libXcursor finds cursors installed into user or system profiles.  See <http://bugs.gnu.org/24445>
-export XCURSOR_PATH=$HOME/.icons:$HOME/.guix-profile/share/icons:/run/current-system/profile/share/icons
+# Set the umask, notably for users logging in via 'lsh'.
+# See <http://bugs.gnu.org/22650>.
+umask 022
 
 # Ignore the default value of 'PATH'.
 unset PATH
@@ -1094,29 +1087,68 @@ (define* (operating-system-etc-service os)
   if [ -f \"$GUIX_PROFILE/etc/profile\" ]
   then
     . \"$GUIX_PROFILE/etc/profile\"
-  else
-    # At least define this one so that basic things just work
-    # when the user installs their first package.
-    export PATH=\"$GUIX_PROFILE/bin:$PATH\"
   fi
+  # At least define this one so that 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
+  # 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>.
+  case $XDG_DATA_DIRS in
+    *$GUIX_PROFILE/share*) ;;
+    *) export XDG_DATA_DIRS=\"$GUIX_PROFILE/share${XDG_DATA_DIRS:+:}$XDG_DATA_DIRS\" ;;
+  esac
+  case $XDG_CONFIG_DIRS in
+    *$GUIX_PROFILE/etc/xdg*) ;;
+    *) export XDG_CONFIG_DIRS=\"$GUIX_PROFILE/etc/xdg${XDG_CONFIG_DIRS:+:}$XDG_CONFIG_DIRS\" ;;
+  esac
+  # When INFOPATH is unset, add a trailing colon so Emacs searches
+  # 'Info-default-directory-list'.
+  case $INFOPATH in
+    *$GUIX_PROFILE/share/info*) ;;
+    *) export INFOPATH=\"$GUIX_PROFILE/share/info:$INFOPATH\" ;;
+  esac
+  # When MANPATH is unset, add a trailing colon so the system default search
+  # path is used.
+  case $MANPATH in
+    *$GUIX_PROFILE/share/man*) ;;
+    *) export MANPATH=\"$GUIX_PROFILE/share/man:$MANPATH\" ;;
+  esac
+  # 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
+  # Make sure libXcursor finds cursors installed into user or system profiles.
+  # See <http://bugs.gnu.org/24445>
+  case $XCURSOR_PATH in
+    *$GUIX_PROFILE/share/icons*) ;;
+    *) export XCURSOR_PATH=\"$GUIX_PROFILE/share/icons${XCURSOR_PATH:+:}$XCURSOR_PATH\" ;;
+  esac
+  # Allow Hunspell-based applications (IceCat, LibreOffice, etc.) to find
+  # dictionaries.
+  case $DICPATH in
+    *$GUIX_PROFILE/share/hunspell*) ;;
+    *) export DICPATH=\"$GUIX_PROFILE/share/hunspell${DICPATH:+:}$DICPATH\" ;;
+  esac
+  # Allow GStreamer-based applications to find plugins.
+  case $GST_PLUGIN_PATH in
+    *$GUIX_PROFILE/lib/gstreamer-1.0*) ;;
+    *) export GST_PLUGIN_PATH=\"$GUIX_PROFILE/lib/gstreamer-1.0${GST_PLUGIN_PATH:+:}$GST_PLUGIN_PATH\" ;;
+  esac
 done
 
-# Prepend privileged programs.
+# Prepend paths not in a profile.
 export PATH=/run/privileged/bin:$PATH
-
-# Arrange so that ~/.config/guix/current/share/info comes first.
-export INFOPATH=\"$HOME/.config/guix/current/share/info:$INFOPATH\"
-
-# Set the umask, notably for users logging in via 'lsh'.
-# See <http://bugs.gnu.org/22650>.
-umask 022
-
-# Allow Hunspell-based applications (IceCat, LibreOffice, etc.) to
-# find dictionaries.
-export DICPATH=\"$HOME/.guix-profile/share/hunspell:/run/current-system/profile/share/hunspell\"
-
-# Allow GStreamer-based applications to find plugins.
-export GST_PLUGIN_PATH=\"$HOME/.guix-profile/lib/gstreamer-1.0\"
+export XCURSOR_PATH=\"$HOME/.icons:$XCURSOR_PATH\"
 
 if [ -n \"$BASH_VERSION\" -a -f /etc/bashrc ]
 then
diff --git a/gnu/system/shadow.scm b/gnu/system/shadow.scm
index b68a818871..cdb804da18 100644
--- a/gnu/system/shadow.scm
+++ b/gnu/system/shadow.scm
@@ -179,16 +179,6 @@ (define %default-bash-profile
 
 # Honor per-interactive-shell startup file
 if [ -f ~/.bashrc ]; then . ~/.bashrc; fi
-
-# 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
 "))
 
 (define %default-zprofile
-- 
2.49.0





Information forwarded to hako <at> ultrarare.space, ludo <at> gnu.org, andrew <at> trop.in, janneke <at> gnu.org, tanguy <at> bioneland.org, guix-patches <at> gnu.org:
bug#77035; Package guix-patches. (Tue, 01 Apr 2025 15:04:04 GMT) Full text and rfc822 format available.

Message #41 received at 77035 <at> debbugs.gnu.org (full text, mbox):

From: Hilton Chain <hako <at> ultrarare.space>
To: 77035 <at> debbugs.gnu.org
Cc: Hilton Chain <hako <at> ultrarare.space>
Subject: [PATCH v3 3/5] system: /etc/profile: Set up extra environment
 variables for Guix Home.
Date: Tue,  1 Apr 2025 23:02:46 +0800
* gnu/system.scm (operating-system-etc-service)[profile]: Set up extra
environment variables for Guix Home.
* gnu/home/services/shells.scm (add-shell-profile-file): Skip
setup-environment if already finished.
* gnu/home/services.scm (environment-variables->setup-environment-script):
Skip initializing home profile if already finished.

Change-Id: Ife4100c6b19f61272525eebc82931c81784fe9e0
---
 gnu/home/services.scm        | 6 +++++-
 gnu/home/services/shells.scm | 6 +++++-
 gnu/system.scm               | 5 +++++
 3 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/gnu/home/services.scm b/gnu/home/services.scm
index 85a43f80ca..6be1a49a90 100644
--- a/gnu/home/services.scm
+++ b/gnu/home/services.scm
@@ -279,7 +279,11 @@ (define (environment-variables->setup-environment-script vars)
 # ~/.profile does)
 GUIX_PROFILE=\"$HOME_ENVIRONMENT/profile\"
 PROFILE_FILE=\"$GUIX_PROFILE/etc/profile\"
-[ -f $PROFILE_FILE ] && . $PROFILE_FILE
+# Skip if already initialized.
+case $INFOPATH in
+  *$GUIX_PROFILE/share/info*) ;;
+  *) [ -f \"$PROFILE_FILE\" ] && . \"$PROFILE_FILE\" ;;
+esac
 
 case $GUIX_LOCPATH in
   *$GUIX_PROFILE/lib/locale*) ;;
diff --git a/gnu/home/services/shells.scm b/gnu/home/services/shells.scm
index bab5730c3d..35c0c52a8e 100644
--- a/gnu/home/services/shells.scm
+++ b/gnu/home/services/shells.scm
@@ -88,7 +88,11 @@ (define (add-shell-profile-file config)
        "shell-profile"
        "\
 HOME_ENVIRONMENT=$HOME/.guix-home
-. $HOME_ENVIRONMENT/setup-environment
+# Skip if already sourced.
+case $INFOPATH in
+  *$HOME_ENVIRONMENT/profile/share/info*) ;;
+  *) . \"$HOME_ENVIRONMENT/setup-environment\" ;;
+esac
 $HOME_ENVIRONMENT/on-first-login
 unset HOME_ENVIRONMENT\n"
        (serialize-configuration
diff --git a/gnu/system.scm b/gnu/system.scm
index 9fb4275b45..71464bb712 100644
--- a/gnu/system.scm
+++ b/gnu/system.scm
@@ -1146,6 +1146,11 @@ (define* (operating-system-etc-service os)
   esac
 done
 
+# 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
+
 # Prepend paths not in a profile.
 export PATH=/run/privileged/bin:$PATH
 export XCURSOR_PATH=\"$HOME/.icons:$XCURSOR_PATH\"
-- 
2.49.0





Information forwarded to hako <at> ultrarare.space, ludo <at> gnu.org, andrew <at> trop.in, janneke <at> gnu.org, tanguy <at> bioneland.org, guix-patches <at> gnu.org:
bug#77035; Package guix-patches. (Tue, 01 Apr 2025 15:04:05 GMT) Full text and rfc822 format available.

Message #44 received at 77035 <at> debbugs.gnu.org (full text, mbox):

From: Hilton Chain <hako <at> ultrarare.space>
To: 77035 <at> debbugs.gnu.org
Cc: Hilton Chain <hako <at> ultrarare.space>
Subject: [PATCH v3 4/5] system & home: profile: Address issues reported by ‘shellcheck’.
Date: Tue,  1 Apr 2025 23:02:47 +0800
* gnu/system.scm (operating-system-etc-service)[profile]: Address issues
reported by ‘shellcheck’.
* gnu/home/services.scm (environment-variables->setup-environment-script):
Likewise.
* gnu/home/services/shells.scm (add-shell-profile-file): Likewise.

Change-Id: I4e230fd239b8a8450da6ee0c2e58746c9cc38785
---
 gnu/home/services.scm        | 16 ++++++++++------
 gnu/home/services/shells.scm |  4 ++--
 gnu/system.scm               | 10 +++++-----
 3 files changed, 17 insertions(+), 13 deletions(-)

diff --git a/gnu/home/services.scm b/gnu/home/services.scm
index 6be1a49a90..769bc1c033 100644
--- a/gnu/home/services.scm
+++ b/gnu/home/services.scm
@@ -287,27 +287,31 @@ (define (environment-variables->setup-environment-script vars)
 
 case $GUIX_LOCPATH in
   *$GUIX_PROFILE/lib/locale*) ;;
-  *) export GUIX_LOCPATH=$GUIX_PROFILE/lib/locale:$GUIX_LOCPATH ;;
+  *) export GUIX_LOCPATH=\"$GUIX_PROFILE/lib/locale${GUIX_LOCPATH:+:}$GUIX_LOCPATH\" ;;
 esac
 case $XDG_DATA_DIRS in
   *$GUIX_PROFILE/share*) ;;
-  *) export XDG_DATA_DIRS=$GUIX_PROFILE/share:$XDG_DATA_DIRS ;;
+  *) export XDG_DATA_DIRS=\"$GUIX_PROFILE/share${XDG_DATA_DIRS:+:}$XDG_DATA_DIRS\" ;;
 esac
+# When MANPATH is unset, add a trailing colon so the system default search path
+# is used.
 case $MANPATH in
   *$GUIX_PROFILE/share/man*) ;;
-  *) export MANPATH=$GUIX_PROFILE/share/man:$MANPATH
+  *) export MANPATH=\"$GUIX_PROFILE/share/man:$MANPATH\" ;;
 esac
+# When INFOPATH is unset, add a trailing colon so Emacs searches
+# 'Info-default-directory-list'.
 case $INFOPATH in
   *$GUIX_PROFILE/share/info*) ;;
-  *) export INFOPATH=$GUIX_PROFILE/share/info:$INFOPATH ;;
+  *) export INFOPATH=\"$GUIX_PROFILE/share/info:$INFOPATH\" ;;
 esac
 case $XDG_CONFIG_DIRS in
   *$GUIX_PROFILE/etc/xdg*) ;;
-  *) export XDG_CONFIG_DIRS=$GUIX_PROFILE/etc/xdg:$XDG_CONFIG_DIRS ;;
+  *) export XDG_CONFIG_DIRS=\"$GUIX_PROFILE/etc/xdg${XDG_CONFIG_DIRS:+:}$XDG_CONFIG_DIRS\" ;;
 esac
 case $XCURSOR_PATH in
   *$GUIX_PROFILE/share/icons*) ;;
-  *) export XCURSOR_PATH=$GUIX_PROFILE/share/icons:$XCURSOR_PATH ;;
+  *) export XCURSOR_PATH=\"$GUIX_PROFILE/share/icons${XCURSOR_PATH:+:}$XCURSOR_PATH\" ;;
 esac
 
 # Keep the shell environment clean.
diff --git a/gnu/home/services/shells.scm b/gnu/home/services/shells.scm
index 35c0c52a8e..97c9331e18 100644
--- a/gnu/home/services/shells.scm
+++ b/gnu/home/services/shells.scm
@@ -87,13 +87,13 @@ (define (add-shell-profile-file config)
      ,(mixed-text-file
        "shell-profile"
        "\
-HOME_ENVIRONMENT=$HOME/.guix-home
+HOME_ENVIRONMENT=\"$HOME/.guix-home\"
 # Skip if already sourced.
 case $INFOPATH in
   *$HOME_ENVIRONMENT/profile/share/info*) ;;
   *) . \"$HOME_ENVIRONMENT/setup-environment\" ;;
 esac
-$HOME_ENVIRONMENT/on-first-login
+\"$HOME_ENVIRONMENT/on-first-login\"
 unset HOME_ENVIRONMENT\n"
        (serialize-configuration
         config
diff --git a/gnu/system.scm b/gnu/system.scm
index 71464bb712..bbf2f2afd3 100644
--- a/gnu/system.scm
+++ b/gnu/system.scm
@@ -1071,11 +1071,11 @@ (define* (operating-system-etc-service os)
 # loaded when someone logs in via SSH.  See <http://bugs.gnu.org/22175>.
 # We need 'PATH' to be defined here, for 'cat' and 'cut'.  Do this before
 # reading the user's 'etc/profile' to allow variables to be overridden.
-if [ -f /etc/environment -a -n \"$SSH_CLIENT\" \\
-     -a -z \"$LINUX_MODULE_DIRECTORY\" ]
+if [ -f /etc/environment ] && [ -n \"$SSH_CLIENT\" ] &&
+     [ -z \"$LINUX_MODULE_DIRECTORY\" ]
 then
   . /etc/environment
-  export `/run/current-system/profile/bin/cut -d= -f1 < /etc/environment`
+  export \"$(/run/current-system/profile/bin/cut -d= -f1 < /etc/environment)\"
 fi
 
 # Set up environment for all default profiles.
@@ -1152,10 +1152,10 @@ (define* (operating-system-etc-service os)
 unset HOME_ENVIRONMENT
 
 # Prepend paths not in a profile.
-export PATH=/run/privileged/bin:$PATH
+export PATH=\"/run/privileged/bin:$PATH\"
 export XCURSOR_PATH=\"$HOME/.icons:$XCURSOR_PATH\"
 
-if [ -n \"$BASH_VERSION\" -a -f /etc/bashrc ]
+if [ -n \"$BASH_VERSION\" ] && [ -f /etc/bashrc ]
 then
   # Load Bash-specific initialization code.
   . /etc/bashrc
-- 
2.49.0





Information forwarded to hako <at> ultrarare.space, ludo <at> gnu.org, guix-patches <at> gnu.org:
bug#77035; Package guix-patches. (Tue, 01 Apr 2025 15:05:02 GMT) Full text and rfc822 format available.

Message #47 received at 77035 <at> debbugs.gnu.org (full text, mbox):

From: Hilton Chain <hako <at> ultrarare.space>
To: 77035 <at> debbugs.gnu.org
Cc: Hilton Chain <hako <at> ultrarare.space>
Subject: [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





Merged 77035 77522 77523 77524 77525 77526 77527 77528. Request was from Hilton Chain <hako <at> ultrarare.space> to control <at> debbugs.gnu.org. (Fri, 04 Apr 2025 03:28:02 GMT) Full text and rfc822 format available.

This bug report was last modified 71 days ago.

Previous Next


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