Man page - nix-env(1)

Packages contains this manual

Manual

nix-env

Name
Synopsis
Description
Package sources
Selectors
Files

Name

nix-env - manipulate or query Nix user environments

Synopsis

nix-env operation [ options ] [ arguments… ] [--option name value ] [--arg name value ] [--argstr name value ] [{--file | -f} path ] [{--profile | -p} path ] [--system-filter system ] [--dry-run]

Description

The command nix-env is used to manipulate Nix user environments. User environments are sets of software packages available to a user at some point in time. In other words, they are a synthesised view of the programs available in the Nix store. There may be many user environments: different users can have different environments, and individual users can switch between different environments.

nix-env takes exactly one operation flag which indicates the subcommand to be performed. The following operations are available:

β€’

--install

β€’

--upgrade

β€’

--uninstall

β€’

--set

β€’

--set-flag

β€’

--query

β€’

--switch-profile

β€’

--list-generations

β€’

--delete-generations

β€’

--switch-generation

β€’

--rollback

These pages can be viewed offline:

β€’

man nix-env-<operation>.

Example: man nix-env-install

β€’

nix-env --help --<operation>

Example: nix-env --help --install

Package sources

nix-env can obtain packages from multiple sources:

β€’

An attribute set of derivations from:

β€’

The default Nix expression (by default)

β€’

A Nix file, specified via --file

β€’

A profile , specified via --from-profile

β€’

A Nix expression that is a function which takes default expression as argument, specified via --from-expression

β€’

A store path

Selectors

Several operations, such as nix-env --query and nix-env --install , take a list of arguments that specify the packages on which to operate.

Packages are identified based on a name part and a version part of a symbolic derivation name :

β€’

name: Everything up to but not including the first dash (-) that is not followed by a letter.

β€’

version: The rest, excluding the separating dash.

Example

nix-env parses the symbolic derivation name apache-httpd-2.0.48 as:

{
"name": "apache-httpd",
"version": "2.0.48"
}

Example

nix-env parses the symbolic derivation name firefox.* as:

{
"name": "firefox.*",
"version": ""
}

The name parts of the arguments to nix-env are treated as extended regular expressions and matched against the name parts of derivation names in the package source. The match is case-sensitive. The regular expression can optionally be followed by a dash (-) and a version number; if omitted, any version of the package will match. For details on regular expressions, see regex (7) .

Example

Common patterns for finding package names with nix-env:

β€’

firefox

Matches the package name firefox and any version.

β€’

firefox-32.0

Matches the package name firefox and version 32.0.

β€’

gtk\\+

Matches the package name gtk+. The + character must be escaped using a backslash (\) to prevent it from being interpreted as a quantifier, and the backslash must be escaped in turn with another backslash to ensure that the shell passes it on.

β€’

.\*

Matches any package name. This is the default for most commands.

β€’

’.*zip.*’

Matches any package name containing the string zip. Note the dots: ’*zip*’ does not work, because in a regular expression, the character * is interpreted as a quantifier.

β€’

’.*(firefox|chromium).*’

Matches any package name containing the strings firefox or chromium.

Files

nix-env operates on the following files.

{{#include ./files/default-nix-expression.md}}

{{#include ./files/profiles.md}}