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

@ -47688,8 +47688,9 @@ not end with @file{.sh} are @emph{not} added to @file{/etc/profile.d/}
and are silently dropped. The default value is made available via the
@var{%default-etc-bashrc-d-files} variable for users to extended.
Package objects can also be provided directly to have their
@file{etc/bashrc.d/*.sh} prefixed files added. An example usage may
look like:
@file{etc/bashrc.d/*.sh} prefixed files added. Since the service is
part @code{%base-services}, it can be extended via @code{simple-service}
like so:
@example
(use-package-modules gnome) ;for the `vte' package
@ -49322,8 +49323,11 @@ Available @code{home-bash-configuration} fields are:
The Bash package to use.
@item @code{guix-defaults?} (default: @code{#t}) (type: boolean)
Add sane defaults like reading @file{/etc/bashrc} and coloring the output of
@command{ls} to the top of the @file{.bashrc} file.
Add sane defaults like setting @env{PS1}, @env{SHELL}, and ensuring
@file{/etc/profile} is sourced for non-interactive SSH shells. If you
use Guix System, is it safe to set this to @code{#f}, as in this case
this is already taken care of by the globally installed
@file{/etc/bashrc}.
@item @code{environment-variables} (default: @code{'()}) (type: alist)
Association list of environment variables to set for the Bash session. The
@ -49331,7 +49335,7 @@ rules for the @code{home-environment-variables-service-type} apply
here (@pxref{Essential Home Services}). The contents of this field will be
added after the contents of the @code{bash-profile} field.
@item @code{aliases} (default: @code{'()}) (type: alist)
@item @code{aliases} (default: @code{%default-bash-aliases}) (type: alist)
Association list of aliases to set for the Bash session. The aliases
will be defined after the contents of the @code{bashrc} field has been
put in the @file{.bashrc} file. The alias will automatically be quoted,