[bug#78308,v3,10/10] news: Add news entry for etc-bashrc-d-service-type.
Commit Message
Hi Maxim,
a follow-up to my previous reply containing my proposal materialised to
a patch.
From c674d1fdf83bb1bc7930b48f9c0333f2936563d2 Mon Sep 17 00:00:00 2001
Message-ID: <c674d1fdf83bb1bc7930b48f9c0333f2936563d2.1747739946.git.sarg@sarg.org.ru>
From: Sergey Trofimov <sarg@sarg.org.ru>
Date: Tue, 20 May 2025 13:18:29 +0200
Subject: [PATCH] source profile.d as intended
Change-Id: I37c0980ca66b2bfb8516df26d3376b16a009f855
---
gnu/system.scm | 10 +---------
guix/build/profiles.scm | 25 +++++++++++++++++++++++--
guix/profiles.scm | 4 +++-
guix/scripts/environment.scm | 4 ++--
4 files changed, 29 insertions(+), 14 deletions(-)
@@ -1134,15 +1134,7 @@ (define* (operating-system-etc-service os)
# Provide a default prompt. The user's ~/.bashrc can override it.
PS1='\\u@\\h \\w${GUIX_ENVIRONMENT:+ [env]}\\$ '
-
-# The 'bash-completion' package.
-if [ -f /run/current-system/profile/etc/profile.d/bash_completion.sh ]
-then
- # Bash-completion sources ~/.bash_completion. It installs a dynamic
- # completion loader that searches its own completion files as well
- # as those in ~/.guix-profile and /run/current-system/profile.
- source /run/current-system/profile/etc/profile.d/bash_completion.sh
-fi\n")))
+")))
(service etc-service-type
`(("os-release" ,os-release)
("services" ,(file-append net-base "/etc/services"))
@@ -98,9 +98,30 @@ (define (build-etc/profile output search-paths)
# to this specific profile generation.
\n" port)
(let ((variables (evaluate-search-paths search-paths
- (list output))))
+ (list output)))
+ (profile-d (string-append output "/etc/profile.d"))
+ (guard-flag (string-append "GUIX_PROFILE_"
+ (string-take (basename output) 32)
+ "_LOADED")))
+
+ (format port "if [ \"x$~a\" = x ]; then\n" guard-flag)
(for-each (write-environment-variable-definition port)
- (map (abstract-profile output) variables))))))
+ (map (abstract-profile output) variables))
+
+ (format port "
+~a=1
+fi
+
+for i in ~a/*.sh; do
+ if [ -r \"$i\" ]; then
+ if [ \"${-#*i}\" != \"$-\" ]; then
+ . \"$i\"
+ else
+ . \"$i\" >/dev/null
+ fi
+ fi
+done"
+ guard-flag profile-d)))))
(define* (ensure-writable-directory directory
#:key (symlink symlink))
@@ -2165,7 +2165,9 @@ (define* (load-profile profile
(string-append value separator current)
value)
value)))))
- (profile-search-paths profile manifest)))
+ (profile-search-paths profile manifest))
+ (setenv (string-append "GUIX_PROFILE_" (string-take (basename profile) 32)
+ "_LOADED") "1"))
(define (profile-regexp profile)
"Return a regular expression that matches PROFILE's name and number."
@@ -1123,8 +1123,8 @@ (define (guix-environment* opts)
(if container?
;; The user's shell is likely not available
;; within the container.
- '("/bin/sh")
- (list %default-shell))))
+ '("/bin/sh" "--login")
+ (list %default-shell "--login"))))
(mappings (pick-all opts 'file-system-mapping))
(white-list (pick-all opts 'inherit-regexp)))
base-commit: e7d73a08d569904f8a71db5b84f5fafaf0dff188
--
2.49.0