[bug#77035,v3,1/5] system: /etc/profile: Set up all default profiles in one iteration.

Message ID 8e99166202077cc58e29db4ece30dbd5bb8d7d8b.1743519525.git.hako@ultrarare.space
State New
Headers
Series system: Rearrange /etc/profile. |

Commit Message

Hilton Chain April 1, 2025, 3:02 p.m. UTC
  * 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(-)
  

Patch

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