nix-env-switch-generation - Man Page

set user environment to given profile generation

Synopsis

nix-env {--switch-generation | -G} generation

Description

This operation makes generation number generation the current generation of the active profile. That is, if the profile is the path to the active profile, then the symlink profile is made to point to profile-generation-link, which is in turn a symlink to the actual user environment in the Nix store.

Switching will fail if the specified generation does not exist.

Options

The following options are allowed for all nix-env operations, but may not always have an effect.

Common Options

Most Nix commands accept the following command-line options:

{ # The system (e.g., `i686-linux') for which to build the packages.
system ? builtins.currentSystem
...
}: ...

So if you call this Nix expression (e.g., when you do nix-env --install --attr pkgname), the function will be called automatically using the value builtins.currentSystem for the system argument. You can override this using --arg, e.g., nix-env --install --attr pkgname --arg system \"i686-freebsd\". (Note that since the argument is a Nix string literal, you have to escape the quotes.)

Environment variables

Common Environment Variables

Most Nix commands interpret the following environment variables:

$ mkdir /nix
$ mount -o bind /mnt/otherdisk/nix /nix

Consult the mount 8 manual page for details.

XDG Base Directories

Nix follows the XDG Base Directory Specification\c .

For backwards compatibility, Nix commands will follow the standard only when use-xdg-base-directories is enabled. New Nix commands (experimental) conform to the standard by default.

The following environment variables are used to determine locations of various state and configuration files:

  • [XDG_CONFIG_HOME]{#env-XDGCONFIGHOME} (default ~/.config)
  • [XDG_STATE_HOME]{#env-XDGSTATEHOME} (default ~/.local/state)
  • [XDG_CACHE_HOME]{#env-XDGCACHEHOME} (default ~/.cache)

In addition, setting the following environment variables overrides the XDG base directories:

  • [NIX_CONFIG_HOME]{#env-NIXCONFIGHOME} (default $XDG_CONFIG_HOME/nix)
  • [NIX_STATE_HOME]{#env-NIXSTATEHOME} (default $XDG_STATE_HOME/nix)
  • [NIX_CACHE_HOME]{#env-NIXCACHEHOME} (default $XDG_CACHE_HOME/nix)

When use-xdg-base-directories is enabled, the configuration directory is:

  1. $NIX_CONFIG_HOME, if it is defined
  2. Otherwise, $XDG_CONFIG_HOME/nix, if XDG_CONFIG_HOME is defined
  3. Otherwise, ~/.config/nix.

Likewise for the state and cache directories.

Examples

$ nix-env --switch-generation 42
switching from generation 50 to 42