Subject: [bug#78308] [PATCH v3 01/10] system: Source scripts from the /etc/profile.d directory.

From: Maxim Cournoyer <[email-masked]>
Date: Mon, 19 May 2025 09:28:59 +0900

This is useful since our /etc/profile file is otherwise not easily
extendable.

* gnu/system.scm (operating-system-etc-service): Source all '.sh' ending
files found under the /etc/profile.d directory.

Change-Id: Ia6d777195241f69219f00fbd5975e3e6b7c265fb
---
 gnu/system.scm | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/gnu/system.scm b/gnu/system.scm
index 2beca4b6d08..7db0ff5ba5e 100644
--- a/gnu/system.scm
+++ b/gnu/system.scm
@@ -1122,6 +1122,17 @@ (define* (operating-system-etc-service os)
 # Allow GStreamer-based applications to find plugins.
 export GST_PLUGIN_PATH=\"$HOME/.guix-profile/lib/gstreamer-1.0\"
 
+for i in /etc/profile.d/*.sh; do
+    if [ -r \"$i\" ]; then
+        if [ \"${-#*i}\" != \"$-\" ]; then
+            . \"$i\"
+        else
+            . \"$i\" >/dev/null
+        fi
+    fi
+done
+unset i
+
 if [ -n \"$BASH_VERSION\" -a -f /etc/bashrc ]
 then
   # Load Bash-specific initialization code.

base-commit: 6b5fc4812981f2cadffcc5d39e48cd8e02ee73af
-- 
2.49.0