GNU bug report logs - #77525
[PATCH v4 2/6] system: /etc/profile: Rearrange to avoid search path duplication.

Previous Next

Package: guix-patches;

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

Date: Fri, 4 Apr 2025 03:24:05 UTC

Severity: normal

Tags: patch

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

To reply to this bug, email your comments to 77525 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 guix-patches <at> gnu.org:
bug#77525; Package guix-patches. (Fri, 04 Apr 2025 03:24:06 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 guix-patches <at> gnu.org. (Fri, 04 Apr 2025 03:24:06 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 v4 2/6] system: /etc/profile: Rearrange to avoid search path
 duplication.
Date: Fri,  4 Apr 2025 11:22:59 +0800
* gnu/system.scm (operating-system-etc-service)[profile]: Set umask first.
Group environment variables setup with profile sourcing to avoid duplication.
Export $GUILE_LOAD_PATH and $GUILE_LOAD_COMPILED_PATH for ‘guix pull’ profile.
* gnu/system/shadow.scm (%default-bash-profile): Remove duplicated exports.

Change-Id: I42ae153b9cd47ca24448fa18ce7f80a5e5c06621
---
 gnu/system.scm        | 96 +++++++++++++++++++++++++++++--------------
 gnu/system/shadow.scm | 10 -----
 2 files changed, 65 insertions(+), 41 deletions(-)

diff --git a/gnu/system.scm b/gnu/system.scm
index c166222854..46e6729e74 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
@@ -1091,32 +1084,73 @@ (define* (operating-system-etc-service os)
                     \"$HOME/.guix-profile\"        \\
                     \"$HOME/.config/guix/current\"
 do
-  if [ -f \"$GUIX_PROFILE/etc/profile\" ]
-  then
+  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\"
+    if [ ! \"$GUIX_PROFILE\" = \"$HOME/.config/guix/current\" ]; then
+      # 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
+      # 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
+    fi
+  fi
+  if [ \"$GUIX_PROFILE\" = \"$HOME/.config/guix/current\" ]; then
+    # 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
   fi
+  # 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
+  # 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
 done
 
-# Prepend privileged programs.
+# Prepend search 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





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.

Information forwarded to guix-patches <at> gnu.org:
bug#77525; Package guix-patches. (Mon, 14 Apr 2025 15:13:01 GMT) Full text and rfc822 format available.

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

From: Ludovic Courtès <ludo <at> gnu.org>
To: Hilton Chain <hako <at> ultrarare.space>
Cc: iyzsong <at> gmail.com, 77525 <at> debbugs.gnu.org,
 宋文武 <iyzsong <at> envs.net>, 77528 <at> debbugs.gnu.org
Subject: Re: [bug#77525] [PATCH v4 2/6] system: /etc/profile: Rearrange to
 avoid search path duplication.
Date: Mon, 14 Apr 2025 17:12:12 +0200
Hi Hilton,

(Cc: 宋文武.)

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

> * gnu/system.scm (operating-system-etc-service)[profile]: Set umask first.
> Group environment variables setup with profile sourcing to avoid duplication.
> Export $GUILE_LOAD_PATH and $GUILE_LOAD_COMPILED_PATH for ‘guix pull’ profile.
> * gnu/system/shadow.scm (%default-bash-profile): Remove duplicated exports.

The last item does not say the whole story:

> +++ 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
>  "))

I am the one who suggested to not invoke ‘guix package’ from shell
startup files:

  https://issues.guix.gnu.org/77035#8-lineno17

However, I hadn’t realized that this had previously been introduced by
宋文武 in commit 40310efde9b4a4f2cf98081d6cd10f843685ebb6.

Since this patch essentially reverts this commit, could you share your
thoughts on this, 宋文武?

Thanks,
Ludo’.




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

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

From: 宋文武 <iyzsong <at> envs.net>
To: Ludovic Courtès <ludo <at> gnu.org>
Cc: Hilton Chain <hako <at> ultrarare.space>, 77525 <at> debbugs.gnu.org,
 77528 <at> debbugs.gnu.org, iyzsong <at> gmail.com
Subject: Re: [bug#77525] [PATCH v4 2/6] system: /etc/profile: Rearrange to
 avoid search path duplication.
Date: Tue, 15 Apr 2025 22:05:06 +0800
Ludovic Courtès <ludo <at> gnu.org> writes:

> [...]
>
> The last item does not say the whole story:
>
>> +++ 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
>>  "))
>
> I am the one who suggested to not invoke ‘guix package’ from shell
> startup files:
>
>   https://issues.guix.gnu.org/77035#8-lineno17
>
> However, I hadn’t realized that this had previously been introduced by
> 宋文武 in commit 40310efde9b4a4f2cf98081d6cd10f843685ebb6.
>
> Since this patch essentially reverts this commit, could you share your
> thoughts on this, 宋文武?

Hi, Sorry for that, it seems I had leave it partly commited in, without
a news entry and documentation.  The change about
/etc/skel/.bash_profile in commit 40310e is to provide a sensible
default to merge multiple profiles, which will fix
<https://issues.guix.gnu.org/20255>.  Users can easily change his own
~/.bash_profile to not invoke 'guix package', to avoid merge multiple
profiles.

Now I think it's better to remove it as the patch did, so we default to
not merge search paths from multiple profiles, and document how to
custom your ~/.bash_profile with 'guix package --search-paths` to merge
them.  Also mention the drawback when you choose to merge profiles for
search paths, mainly ABI incompatible problems from plugins (GIO
modules, Qt, etc.).

Thanks.




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

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

From: Ludovic Courtès <ludo <at> gnu.org>
To: 宋文武 <iyzsong <at> envs.net>
Cc: Hilton Chain <hako <at> ultrarare.space>, 77525 <at> debbugs.gnu.org,
 77528 <at> debbugs.gnu.org, iyzsong <at> gmail.com
Subject: Re: [bug#77525] [PATCH v4 2/6] system: /etc/profile: Rearrange to
 avoid search path duplication.
Date: Tue, 15 Apr 2025 17:05:02 +0200
宋文武 <iyzsong <at> envs.net> writes:

> Hi, Sorry for that, it seems I had leave it partly commited in, without
> a news entry and documentation.  The change about
> /etc/skel/.bash_profile in commit 40310e is to provide a sensible
> default to merge multiple profiles, which will fix
> <https://issues.guix.gnu.org/20255>.  Users can easily change his own
> ~/.bash_profile to not invoke 'guix package', to avoid merge multiple
> profiles.
>
> Now I think it's better to remove it as the patch did, so we default to
> not merge search paths from multiple profiles,

OK, I see.

Any thoughts on the patch series Hilton submitted?

  https://issues.guix.gnu.org/77035

Thanks for your feedback,
Ludo’.




Information forwarded to guix-patches <at> gnu.org:
bug#77525; Package guix-patches. (Sat, 19 Apr 2025 02:10:07 GMT) Full text and rfc822 format available.

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

From: 宋文武 <iyzsong <at> envs.net>
To: Hilton Chain <hako <at> ultrarare.space>
Cc: 77525 <at> debbugs.gnu.org
Subject: Re: [bug#77525] [PATCH v4 2/6] system: /etc/profile: Rearrange to
 avoid search path duplication.
Date: Sat, 19 Apr 2025 10:13:52 +0800
Hilton Chain <hako <at> ultrarare.space> writes:

> * gnu/system.scm (operating-system-etc-service)[profile]: Set umask first.
OK.

> Group environment variables setup with profile sourcing to avoid duplication.
It was already grouped in previous commit, maybe "Setup crucial
variables from all the default profiles."

> Export $GUILE_LOAD_PATH and $GUILE_LOAD_COMPILED_PATH for ‘guix pull’ profile.
Could be a seperated commit, but maybe not needed?  Since 'guix repl'
would ensure it.

> * gnu/system/shadow.scm (%default-bash-profile): Remove duplicated exports.
I think this better go into a seperated commit, and with comment or
cookbook doc for the merge search paths from multiple profiles usage.

> [...]
>  do
> -  if [ -f \"$GUIX_PROFILE/etc/profile\" ]
> -  then
> +  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\"
> +    if [ ! \"$GUIX_PROFILE\" = \"$HOME/.config/guix/current\" ]; then
> +      # 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
> +      # Make sure libXcursor finds cursors installed into user or system profiles.
> +      # See <http://bugs.gnu.org/24445>

Commit 2acfafff set XCURSORPATH contains user and system profiles, but
not home profile as this patch did, this comment about 24445 can be
removed.

Otherwise, look good to me!




This bug report was last modified 103 days ago.

Previous Next


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