Previous: , Up: Home Configuration   [Contents][Index]


13.4 Invoking guix home

Once you have written a home environment declaration (see Declaring the Home Environment, it can be instantiated using the guix home command. The synopsis is:

guix home optionsaction file

file must be the name of a file containing a home-environment declaration. action specifies how the home environment is instantiated, but there are few auxiliary actions which don’t instantiate it. Currently the following values are supported:

search

Display available home service type definitions that match the given regular expressions, sorted by relevance:

$ guix home search shell
name: home-shell-profile
location: gnu/home/services/shells.scm:100:2
extends: home-files
description: Create `~/.profile', which is used for environment initialization of POSIX compliant login shells.
+ This service type can be extended with a list of file-like objects.
relevance: 6

name: home-fish
location: gnu/home/services/shells.scm:640:2
extends: home-files home-profile
description: Install and configure Fish, the friendly interactive shell.
relevance: 3

name: home-zsh
location: gnu/home/services/shells.scm:290:2
extends: home-files home-profile
description: Install and configure Zsh.
relevance: 1

name: home-bash
location: gnu/home/services/shells.scm:508:2
extends: home-files home-profile
description: Install and configure GNU Bash.
relevance: 1

…

As for guix search, the result is written in recutils format, which makes it easy to filter the output (see GNU recutils databases in GNU recutils manual).

容器

Spawn a shell in an isolated environment—a container—containing your home as specified by file.

For example, this is how you would start an interactive shell in a container with your home:

guix home container config.scm

This is a throw-away container where you can lightheartedly fiddle with files; any changes made within the container, any process started—all this disappears as soon as you exit that shell.

As with guix shell, several options control that container:

--network
-N

Enable networking within the container (it is disabled by default).

--expose=source[=target]
--share=source[=target]

As with guix shell, make directory source of the host system available as target inside the container—read-only if you pass --expose, and writable if you pass --share (see --expose and --share).

Additionally, you can run a command in that container, instead of spawning an interactive shell. For instance, here is how you would check which Shepherd services are started in a throw-away home container:

guix home container config.scm -- herd status

The command to run in the container must come after -- (double hyphen).

edit

Edit or view the definition of the given Home service types.

For example, the command below opens your editor, as specified by the EDITOR environment variable, on the definition of the home-mcron service type:

guix home edit home-mcron
reconfigure

Build the home environment described in file, and switch to it. Switching means that the activation script will be evaluated and (in basic scenario) symlinks to configuration files generated from home-environment declaration will be created in ~. If the file with the same path already exists in home folder it will be moved to ~/timestamp-guix-home-legacy-configs-backup, where timestamp is a current UNIX epoch time.

注: It is highly recommended to run guix pull once before you run guix home reconfigure for the first time (see Invoking guix pull).

This effects all the configuration specified in file. The command starts Shepherd services specified in file that are not currently running; if a service is currently running, this command will arrange for it to be upgraded the next time it is stopped (e.g. by herd stop service or herd restart service).

This command creates a new generation whose number is one greater than the current generation (as reported by guix home list-generations). If that generation already exists, it will be overwritten. This behavior mirrors that of guix package (see Invoking guix package).

Upon completion, the new home is deployed under ~/.guix-home. This directory contains provenance meta-data: the list of channels in use (see 通道) and file itself, when available. You can view the provenance information by running:

guix home describe

This information is useful should you later want to inspect how this particular generation was built. In fact, assuming file is self-contained, you can later rebuild generation n of your home environment with:

guix time-machine \
  -C /var/guix/profiles/per-user/USER/guix-home-n-link/channels.scm -- \
  home reconfigure \
  /var/guix/profiles/per-user/USER/guix-home-n-link/configuration.scm

You can think of it as some sort of built-in version control! Your home is not just a binary artifact: it carries its own source.

switch-generation

Switch to an existing home generation. This action atomically switches the home profile to the specified home generation.

The target generation can be specified explicitly by its generation number. For example, the following invocation would switch to home generation 7:

guix home switch-generation 7

The target generation can also be specified relative to the current generation with the form +N or -N, where +3 means “3 generations ahead of the current generation,” and -1 means “1 generation prior to the current generation.” When specifying a negative value such as -1, you must precede it with -- to prevent it from being parsed as an option. For example:

guix home switch-generation -- -1

This action will fail if the specified generation does not exist.

roll-back

Switch to the preceding home generation. This is the inverse of reconfigure, and it is exactly the same as invoking switch-generation with an argument of -1.

delete-generations

Delete home generations, making them candidates for garbage collection (see Invoking guix gc, for information on how to run the “garbage collector”).

This works in the same way as ‘guix package --delete-generations’ (see --delete-generations). With no arguments, all home generations but the current one are deleted:

guix home delete-generations

You can also select the generations you want to delete. The example below deletes all the home generations that are more than two months old:

guix home delete-generations 2m
build

Build the derivation of the home environment, which includes all the configuration files and programs needed. This action does not actually install anything.

describe

Describe the current home generation: its file name, as well as provenance information when available.

To show installed packages in the current home generation’s profile, the --list-installed flag is provided, with the same syntax that is used in guix package --list-installed (see Invoking guix package). For instance, the following command shows a table of all the packages with “emacs” in their name that are installed in the current home generation’s profile:

guix home describe --list-installed=emacs
list-generations

List a summary of each generation of the home environment available on disk, in a human-readable way. This is similar to the --list-generations option of guix package (see Invoking guix package).

Optionally, one can specify a pattern, with the same syntax that is used in guix package --list-generations, to restrict the list of generations displayed. For instance, the following command displays generations that are up to 10 days old:

guix home list-generations 10d

The --list-installed flag may also be specified, with the same syntax that is used in guix home describe. This may be helpful if trying to determine when a package was added to the home profile.

import

Generate a home environment from the packages in the default profile and configuration files found in the user’s home directory. The configuration files will be copied to the specified directory, and a home-configuration.scm will be populated with the home environment. Note that not every home service that exists is supported (see Home Services).

$ guix home import ~/guix-config
guix home: '/home/alice/guix-config' populated with all the Home configuration files

And there’s more! guix home also provides the following sub-commands to visualize how the services of your home environment relate to one another:

extension-graph

Emit to standard output the service extension graph of the home environment defined in file (see 合成服务, for more information on service extensions). By default the output is in Dot/Graphviz format, but you can choose a different format with --graph-backend, as with guix graph (see --backend):

The command:

guix home extension-graph file | xdot -

shows the extension relations among services.

shepherd-graph

Emit to standard output the dependency graph of shepherd services of the home environment defined in file. See Shepherd服务, for more information and for an example graph.

Again, the default output format is Dot/Graphviz, but you can pass --graph-backend to select a different one.

options can contain any of the common build options (see 普通的构建选项). In addition, options can contain one of the following:

--expression=expr
-e expr

Consider the home-environment expr evaluates to. This is an alternative to specifying a file which evaluates to a home environment.

--allow-downgrades

Instruct guix home reconfigure to allow system downgrades.

Just like guix system, guix home reconfigure, by default, prevents you from downgrading your home to older or unrelated revisions compared to the channel revisions that were used to deploy it—those shown by guix home describe. Using --allow-downgrades allows you to bypass that check, at the risk of downgrading your home—be careful!


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