[bug#78308,v2,1/9] system: Source scripts from the /etc/profile.d directory.

Message ID 5cf9f21c9626bb8c8357089caa747c2ae8ae2fca.1747103508.git.maxim.cournoyer@gmail.com
State New
Headers
Series [bug#78308,v2,1/9] system: Source scripts from the /etc/profile.d directory. |

Commit Message

Maxim Cournoyer May 13, 2025, 2:31 a.m. UTC
  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(+)


base-commit: 364694773ef1c61d4c9ec73e24f73642786486ca
  

Patch

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.