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

Message ID d5140275d1f166b9ca890fceb4805e48a8b5c975.1746682206.git.maxim.cournoyer@gmail.com
State New
Headers
Series VTE integration support / Shell startup files refactor |

Commit Message

Maxim Cournoyer May 8, 2025, 6:02 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(+)
  

Patch

diff --git a/gnu/system.scm b/gnu/system.scm
index bc652b1ce59..11ac22da5a0 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.