1
Fork 0
mirror of https://https.git.savannah.gnu.org/git/guix.git/ synced 2025-07-09 23:50:47 +02:00

system: Factorize bashrc default configuration.

This factorizes out the remaining bashrc bits from /etc/skel/.bashrc to a the
template used for both /etc/bashrc on Guix System and ~/.bashrc for
home-bash-service-type.

Rationale: The use of /etc/skel introduce state: the file is only copied
originally when the user account is created, and never (automatically)
refreshed again.

* gnu/system.scm (operating-system-etc-service):
<profile>: Guard against souring /etc/bashrc in non-interactive, SSH case.
<bashrc>: Use %default-bashrc, having migrated the remaining definitions to...
* gnu/system/shadow.scm (%default-bashrc): ... here.  Factorize aliases to...
* gnu/services.scm (%default-bash-aliases): ... here.
(%default-bashrc-d-aliases): New variable.
(%default-etc-bashrc-d-files): Include it in the default configuration.
* gnu/services/base.scm (%base-services): Register etc-bashrc-d-service-type.
* gnu/home/services/shells.scm (add-bash-configuration): Do not set PS1, now
part of %default-bashrc.
(home-bash-configuration) [guix-defaults?]: Update doc.
[aliases]: Set %default-bash-aliases as the default value.  Update doc.
* doc/guix.texi (Shells Home Services): Update documentation.
(Service Reference): Update example.

Change-Id: I340c614983a78fd20a9c4a9705e7fc542ae9b513
This commit is contained in:
Maxim Cournoyer 2025-05-08 11:03:35 +09:00
parent 45b883a9d3
commit c743d646ee
No known key found for this signature in database
GPG key ID: 1260E46482E63562
7 changed files with 68 additions and 47 deletions

View file

@ -1141,23 +1141,13 @@ for i in /etc/profile.d/*.sh; do
done
unset i
if [ -n \"$BASH_VERSION\" -a -f /etc/bashrc ]
then
# Load Bash-specific initialization code.
. /etc/bashrc
if [ -n \"$BASH_VERSION\" -a -f /etc/bashrc ]; then
# Load Bash-specific initialization code, taking care to not source
# /etc/bashrc when invoked from a non-interactive SSH shell,
# to avoid recursion (/etc/bashrc also sources /etc/profile
# in the non-login, non-interactive SSH case).
[[ $- != *i* && -n $SSH_CLIENT ]] || source /etc/bashrc
fi
"))
(bashrc (plain-file "bashrc" "\
# Bash-specific initialization.
# Provide a default prompt. The user's ~/.bashrc can override it.
PS1='\\u@\\h \\w${GUIX_ENVIRONMENT:+ [env]}\\$ '
for i in /etc/bashrc.d/*.sh; do
[[ -r $i ]] && source \"$i\"
done
unset i
")))
(service etc-service-type
`(("os-release" ,os-release)
@ -1168,7 +1158,7 @@ unset i
("issue" ,issue)
,@(if nsswitch `(("nsswitch.conf" ,nsswitch)) '())
("profile" ,profile)
("bashrc" ,bashrc)
("bashrc" ,%default-bashrc)
;; Write the operating-system-host-name to /etc/hostname to prevent
;; NetworkManager from changing the system's hostname when connecting
;; to certain networks. Some discussion at