GNU bug report logs - #77523
[PATCH v4 1/6] system: /etc/profile: Group profile sourcing.

Previous Next

Package: guix-patches;

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

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

Severity: normal

Tags: patch

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

To reply to this bug, email your comments to 77523 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#77523; Package guix-patches. (Fri, 04 Apr 2025 03:24:04 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:04 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 1/6] system: /etc/profile: Group profile sourcing.
Date: Fri,  4 Apr 2025 11:22:58 +0800
* gnu/system.scm (operating-system-etc-service)[profile]: Group sourcing of
all default profiles.
Order Guix Home search paths before the default user profile.
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





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#77523; Package guix-patches. (Sat, 19 Apr 2025 01:34:04 GMT) Full text and rfc822 format available.

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

From: 宋文武 <iyzsong <at> envs.net>
To: Hilton Chain <hako <at> ultrarare.space>
Cc: 77523 <at> debbugs.gnu.org
Subject: Re: [bug#77523] [PATCH v4 1/6] system: /etc/profile: Group profile
 sourcing.
Date: Sat, 19 Apr 2025 09:37:54 +0800
Hi,

Hilton Chain <hako <at> ultrarare.space> writes:
> * gnu/system.scm (operating-system-etc-service)[profile]: Group sourcing of
> all default profiles.
> Order Guix Home search paths before the default user profile.

Seems reversed, maybe "Prefer search paths of the default user profile
over the home profile.

> 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
This "We need ... to allow variables to be overridden." comment should
be removed, since it's for the previous "Load the system profile's settings.".


> [...]
> -# 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

Since we are here, I think we can append "unset GUIX_PROFILE" after the
for loop to show it no longer needed, and avoid possibly wrong usages.




This bug report was last modified 55 days ago.

Previous Next


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