Next: , Previous: , Up: Home Services   [Contents][Index]


11.3.2 Shells

Shells play a quite important role in the environment initialization process, you can configure them manually as described in section Configuring the Shell, but the recommended way is to use home services listed below. It’s both easier and more reliable.

Each home environment instantiates home-shell-profile-service-type, which creates a ~/.profile startup file for all POSIX-compatible shells. This file contains all the necessary steps to properly initialize the environment, but many modern shells like Bash or Zsh prefer their own startup files, that’s why the respective home services (home-bash-service-type and home-zsh-service-type) ensure that ~/.profile is sourced by ~/.bash_profile and ~/.zprofile, respectively.

Shell Profile Service

Data Type: home-shell-profile-configuration

Available home-shell-profile-configuration fields are:

profile (default: ()) (type: text-config)

home-shell-profile is instantiated automatically by home-environment, DO NOT create this service manually, it can only be extended. profile is a list of file-like objects, which will go to ~/.profile. By default ~/.profile contains the initialization code, which have to be evaluated by login shell to make home-environment’s profile avaliable to the user, but other commands can be added to the file if it is really necessary. In most cases shell’s configuration files are preferred places for user’s customizations. Extend home-shell-profile service only if you really know what you do.

Bash Home Service

Data Type: home-bash-configuration

Available home-bash-configuration fields are:

package (default: bash) (type: package)

The Bash package to use.

guix-defaults? (default: #t) (type: boolean)

Add sane defaults like reading /etc/bashrc and coloring the output of ls to the end of the .bashrc file.

environment-variables (default: ()) (type: alist)

Association list of environment variables to set for the Bash session. The rules for the home-environment-variables-service-type apply here (see Essential Home Services). The contents of this field will be added after the contents of the bash-profile field.

aliases (default: ()) (type: alist)

Association list of aliases to set for the Bash session. The aliases will be defined after the contents of the bashrc field has been put in the .bashrc file. The alias will automatically be quoted, so something line this:

'((\"ls\" . \"ls -alF\"))

turns into

alias ls=\"ls -alF\"
bash-profile (default: ()) (type: text-config)

List of file-like objects, which will be added to .bash_profile. Used for executing user’s commands at start of login shell (In most cases the shell started on tty just after login). .bash_login won’t be ever read, because .bash_profile always present.

bashrc (default: ()) (type: text-config)

List of file-like objects, which will be added to .bashrc. Used for executing user’s commands at start of interactive shell (The shell for interactive usage started by typing bash or by terminal app or any other program).

bash-logout (default: ()) (type: text-config)

List of file-like objects, which will be added to .bash_logout. Used for executing user’s commands at the exit of login shell. It won’t be read in some cases (if the shell terminates by exec’ing another process for example).

You can extend the Bash service by using the home-bash-extension configuration record, whose fields most mirror that of home-bash-configuration (see home-bash-configuration). The contents of the extensions will be added to the end of the corresponding Bash configuration files (see Bash Startup Files in The GNU Bash Reference Manual.

Data Type: home-bash-extension

Available home-bash-extension fields are:

environment-variables (default: ()) (type: alist)

Additional environment variables to set. These will be combined with the environment variables from other extensions and the base service to form one coherent block of environment variables.

aliases (default: ()) (type: alist)

Additional aliases to set. These will be combined with the aliases from other extensions and the base service.

bash-profile (default: ()) (type: text-config)

Additional text blocks to add to .bash_profile, which will be combined with text blocks from other extensions and the base service.

bashrc (default: ()) (type: text-config)

Additional text blocks to add to .bashrc, which will be combined with text blocks from other extensions and the base service.

bash-logout (default: ()) (type: text-config)

Additional text blocks to add to .bash_logout, which will be combined with text blocks from other extensions and the base service.

Zsh Home Service

Data Type: home-zsh-configuration

Available home-zsh-configuration fields are:

package (default: zsh) (type: package)

The Zsh package to use.

xdg-flavor? (default: #t) (type: boolean)

Place all the configs to $XDG_CONFIG_HOME/zsh. Makes ~/.zshenv to set ZDOTDIR to $XDG_CONFIG_HOME/zsh. Shell startup process will continue with $XDG_CONFIG_HOME/zsh/.zshenv.

environment-variables (default: ()) (type: alist)

Association list of environment variables to set for the Zsh session.

zshenv (default: ()) (type: text-config)

List of file-like objects, which will be added to .zshenv. Used for setting user’s shell environment variables. Must not contain commands assuming the presence of tty or producing output. Will be read always. Will be read before any other file in ZDOTDIR.

zprofile (default: ()) (type: text-config)

List of file-like objects, which will be added to .zprofile. Used for executing user’s commands at start of login shell (In most cases the shell started on tty just after login). Will be read before .zlogin.

zshrc (default: ()) (type: text-config)

List of file-like objects, which will be added to .zshrc. Used for executing user’s commands at start of interactive shell (The shell for interactive usage started by typing zsh or by terminal app or any other program).

zlogin (default: ()) (type: text-config)

List of file-like objects, which will be added to .zlogin. Used for executing user’s commands at the end of starting process of login shell.

zlogout (default: ()) (type: text-config)

List of file-like objects, which will be added to .zlogout. Used for executing user’s commands at the exit of login shell. It won’t be read in some cases (if the shell terminates by exec’ing another process for example).


Next: , Previous: , Up: Home Services   [Contents][Index]