.\" -*- mode: troff; coding: utf-8 -*- .TH "nix-env \(enquery" "1" "" .SH Name .LP \fCnix-env --query\fR - display information about packages .SH Synopsis .LP \fCnix-env\fR {\fC--query\fR | \fC-q\fR} \fInames…\fR [\fC--installed\fR | \fC--available\fR | \fC-a\fR] [{\fC--status\fR | \fC-s\fR}] [{\fC--attr-path\fR | \fC-P\fR}] [\fC--no-name\fR] [{\fC--compare-versions\fR | \fC-c\fR}] [\fC--system\fR] [\fC--drv-path\fR] [\fC--out-path\fR] [\fC--description\fR] [\fC--meta\fR] [\fC--xml\fR] [\fC--json\fR] [{\fC--prebuilt-only\fR | \fC-b\fR}] [{\fC--attr\fR | \fC-A\fR} \fIattribute-path\fR] .SH Description .LP The query operation displays information about either the store paths that are installed in the current generation of the active profile (\fC--installed\fR), or the derivations that are available for installation in the active Nix expression (\fC--available\fR). It only prints information about derivations whose symbolic name matches one of \fInames\fR. .PP The derivations are sorted by their \fCname\fR attributes. .SH Source selection .LP The following flags specify the set of things on which the query operates. .IP "\(bu" 3 \fC--installed\fR .br The query operates on the store paths that are installed in the current generation of the active profile. This is the default. .IP "\(bu" 3 \fC--available\fR; \fC-a\fR .br The query operates on the derivations that are available in the active Nix expression. .SH Queries .LP The following flags specify what information to display about the selected derivations. Multiple flags may be specified, in which case the information is shown in the order given here. Note that the name of the derivation is shown unless \fC--no-name\fR is specified. .IP "\(bu" 3 \fC--xml\fR .br Print the result in an XML representation suitable for automatic processing by other tools. The root element is called \fCitems\fR, which contains a \fCitem\fR element for each available or installed derivation. The fields discussed below are all stored in attributes of the \fCitem\fR elements. .IP "\(bu" 3 \fC--json\fR .br Print the result in a JSON representation suitable for automatic processing by other tools. .IP "\(bu" 3 \fC--prebuilt-only\fR / \fC-b\fR .br Show only derivations for which a substitute is registered, i.e., there is a pre-built binary available that can be downloaded in lieu of building the derivation. Thus, this shows all packages that probably can be installed quickly. .IP "\(bu" 3 \fC--status\fR; \fC-s\fR .br Print the \fIstatus\fR of the derivation. The status consists of three characters. The first is \fCI\fR or \fC-\fR, indicating whether the derivation is currently installed in the current generation of the active profile. This is by definition the case for \fC--installed\fR, but not for \fC--available\fR. The second is \fCP\fR or \fC-\fR, indicating whether the derivation is present on the system. This indicates whether installation of an available derivation will require the derivation to be built. The third is \fCS\fR or \fC-\fR, indicating whether a substitute is available for the derivation. .IP "\(bu" 3 \fC--attr-path\fR; \fC-P\fR .br Print the \fIattribute path\fR of the derivation, which can be used to unambiguously select it using the \fC--attr\fR option available in commands that install derivations like \fCnix-env --install\fR. This option only works together with \fC--available\fR .IP "\(bu" 3 \fC--no-name\fR .br Suppress printing of the \fCname\fR attribute of each derivation. .IP "\(bu" 3 \fC--compare-versions\fR / \fC-c\fR .br Compare installed versions to available versions, or vice versa (if \fC--available\fR is given). This is useful for quickly seeing whether upgrades for installed packages are available in a Nix expression. A column is added with the following meaning: .RS .IP "\(bu" 3 \fC<\fR \fIversion\fR .br A newer version of the package is available or installed. .IP "\(bu" 3 \fC=\fR \fIversion\fR .br At most the same version of the package is available or installed. .IP "\(bu" 3 \fC>\fR \fIversion\fR .br Only older versions of the package are available or installed. .IP "\(bu" 3 \fC- ?\fR .br No version of the package is available or installed. .RE .IP "\(bu" 3 \fC--system\fR .br Print the \fCsystem\fR attribute of the derivation. .IP "\(bu" 3 \fC--drv-path\fR .br Print the path of the \fBstore derivation\fR. .IP "\(bu" 3 \fC--out-path\fR .br Print the output path of the derivation. .IP "\(bu" 3 \fC--description\fR .br Print a short (one-line) description of the derivation, if available. The description is taken from the \fCmeta.description\fR attribute of the derivation. .IP "\(bu" 3 \fC--meta\fR .br Print all of the meta-attributes of the derivation. This option is only available with \fC--xml\fR or \fC--json\fR. .SH Options .LP The following options are allowed for all \fCnix-env\fR operations, but may not always have an effect. .IP "\(bu" 3 \fC--file\fR / \fC-f\fR \fIpath\fR .br Specifies the Nix expression (designated below as the \fIactive Nix expression\fR) used by the \fC--install\fR, \fC--upgrade\fR, and \fC--query --available\fR operations to obtain derivations. The default is \fC\(ti/.nix-defexpr\fR. .IP If the argument starts with \fChttp://\fR or \fChttps://\fR, it is interpreted as the URL of a tarball that will be downloaded and unpacked to a temporary location. The tarball must include a single top-level directory containing at least a file named \fCdefault.nix\fR. .IP "\(bu" 3 \fC--profile\fR / \fC-p\fR \fIpath\fR .br Specifies the profile to be used by those operations that operate on a profile (designated below as the \fIactive profile\fR). A profile is a sequence of user environments called \fIgenerations\fR, one of which is the \fIcurrent generation\fR. .IP "\(bu" 3 \fC--dry-run\fR .br For the \fC--install\fR, \fC--upgrade\fR, \fC--uninstall\fR, \fC--switch-generation\fR, \fC--delete-generations\fR and \fC--rollback\fR operations, this flag will cause \fCnix-env\fR to print what \fIwould\fR be done if this flag had not been specified, without actually doing it. .IP \fC--dry-run\fR also prints out which paths will be \fBsubstituted\fR (i.e., downloaded) and which paths will be built from source (because no substitute is available). .IP "\(bu" 3 \fC--system-filter\fR \fIsystem\fR .br By default, operations such as \fC--query --available\fR show derivations matching any platform. This option allows you to use derivations for the specified platform \fIsystem\fR. .SH Common Options .LP Most Nix commands accept the following command-line options: .IP "\(bu" 3 \fB\fC--help\fR\fR .IP Prints out a summary of the command syntax and exits. .IP "\(bu" 3 \fB\fC--version\fR\fR .IP Prints out the Nix version number on standard output and exits. .IP "\(bu" 3 \fB\fC--verbose\fR\fR / \fC-v\fR .IP Increases the level of verbosity of diagnostic messages printed on standard error. For each Nix operation, the information printed on standard output is well-defined; any diagnostic information is printed on standard error, never on standard output. .IP This option may be specified repeatedly. Currently, the following verbosity levels exist: .RS .IP "\(bu" 3 \fC0\fR “Errors only” .RE .IP Only print messages explaining why the Nix invocation failed. .RS .IP "\(bu" 3 \fC1\fR “Informational” .RE .IP Print \fIuseful\fR messages about what Nix is doing. This is the default. .RS .IP "\(bu" 3 \fC2\fR “Talkative” .RE .IP Print more informational messages. .RS .IP "\(bu" 3 \fC3\fR “Chatty” .RE .IP Print even more informational messages. .RS .IP "\(bu" 3 \fC4\fR “Debug” .RE .IP Print debug information. .RS .IP "\(bu" 3 \fC5\fR “Vomit” .RE .IP Print vast amounts of debug information. .IP "\(bu" 3 \fB\fC--quiet\fR\fR .IP Decreases the level of verbosity of diagnostic messages printed on standard error. This is the inverse option to \fC-v\fR / \fC--verbose\fR. .IP This option may be specified repeatedly. See the previous verbosity levels list. .IP "\(bu" 3 \fB\fC--log-format\fR\fR \fIformat\fR .IP This option can be used to change the output of the log format, with \fIformat\fR being one of: .RS .IP "\(bu" 3 \fCraw\fR .RE .IP This is the raw format, as outputted by nix-build. .RS .IP "\(bu" 3 \fCinternal-json\fR .RE .IP Outputs the logs in a structured manner. .RS .IP \fBWarning\fR .IP While the schema itself is relatively stable, the format of the error-messages (namely of the \fCmsg\fR-field) can change between releases. .RE .RS .IP "\(bu" 3 \fCbar\fR .RE .IP Only display a progress bar during the builds. .RS .IP "\(bu" 3 \fCbar-with-logs\fR .RE .IP Display the raw logs, with the progress bar at the bottom. .IP "\(bu" 3 \fB\fC--no-build-output\fR\fR / \fC-Q\fR .IP By default, output written by builders to standard output and standard error is echoed to the Nix command\(cqs standard error. This option suppresses this behaviour. Note that the builder\(cqs standard output and error are always written to a log file in \fCprefix/nix/var/log/nix\fR. .IP "\(bu" 3 \fB\fC--max-jobs\fR\fR / \fC-j\fR \fInumber\fR .IP Sets the maximum number of build jobs that Nix will perform in parallel to the specified number. Specify \fCauto\fR to use the number of CPUs in the system. The default is specified by the \fCmax-jobs\fR configuration setting, which itself defaults to \fC1\fR. A higher value is useful on SMP systems or to exploit I/O latency. .IP Setting it to \fC0\fR disallows building on the local machine, which is useful when you want builds to happen only on remote builders. .IP "\(bu" 3 \fB\fC--cores\fR\fR .IP Sets the value of the \fCNIX_BUILD_CORES\fR environment variable in the invocation of builders. Builders can use this variable at their discretion to control the maximum amount of parallelism. For instance, in Nixpkgs, if the derivation attribute \fCenableParallelBuilding\fR is set to \fCtrue\fR, the builder passes the \fC-jN\fR flag to GNU Make. It defaults to the value of the \fCcores\fR configuration setting, if set, or \fC1\fR otherwise. The value \fC0\fR means that the builder should use all available CPU cores in the system. .IP "\(bu" 3 \fB\fC--max-silent-time\fR\fR .IP Sets the maximum number of seconds that a builder can go without producing any data on standard output or standard error. The default is specified by the \fCmax-silent-time\fR configuration setting. \fC0\fR means no time-out. .IP "\(bu" 3 \fB\fC--timeout\fR\fR .IP Sets the maximum number of seconds that a builder can run. The default is specified by the \fCtimeout\fR configuration setting. \fC0\fR means no timeout. .IP "\(bu" 3 \fB\fC--keep-going\fR\fR / \fC-k\fR .IP Keep going in case of failed builds, to the greatest extent possible. That is, if building an input of some derivation fails, Nix will still build the other inputs, but not the derivation itself. Without this option, Nix stops if any build fails (except for builds of substitutes), possibly killing builds in progress (in case of parallel or distributed builds). .IP "\(bu" 3 \fB\fC--keep-failed\fR\fR / \fC-K\fR .IP Specifies that in case of a build failure, the temporary directory (usually in \fC/tmp\fR) in which the build takes place should not be deleted. The path of the build directory is printed as an informational message. .IP "\(bu" 3 \fB\fC--fallback\fR\fR .IP Whenever Nix attempts to build a derivation for which substitutes are known for each output path, but realising the output paths through the substitutes fails, fall back on building the derivation. .IP The most common scenario in which this is useful is when we have registered substitutes in order to perform binary distribution from, say, a network repository. If the repository is down, the realisation of the derivation will fail. When this option is specified, Nix will build the derivation instead. Thus, installation from binaries falls back on installation from source. This option is not the default since it is generally not desirable for a transient failure in obtaining the substitutes to lead to a full build from source (with the related consumption of resources). .IP "\(bu" 3 \fB\fC--readonly-mode\fR\fR .IP When this option is used, no attempt is made to open the Nix database. Most Nix operations do need database access, so those operations will fail. .IP "\(bu" 3 \fB\fC--arg\fR\fR \fIname\fR \fIvalue\fR .IP This option is accepted by \fCnix-env\fR, \fCnix-instantiate\fR, \fCnix-shell\fR and \fCnix-build\fR. When evaluating Nix expressions, the expression evaluator will automatically try to call functions that it encounters. It can automatically call functions for which every argument has a \fBdefault value\fR (e.g., \fC{ argName ? defaultValue }: ...\fR). .IP With \fC--arg\fR, you can also call functions that have arguments without a default value (or override a default value). That is, if the evaluator encounters a function with an argument named \fIname\fR, it will call it with value \fIvalue\fR. .IP For instance, the top-level \fCdefault.nix\fR in Nixpkgs is actually a function: .LP .EX { # The system (e.g., \(gai686-linux') for which to build the packages. system ? builtins.currentSystem \&... }: ... .EE .IP So if you call this Nix expression (e.g., when you do \fCnix-env --install --attr pkgname\fR), the function will be called automatically using the value \fB\fCbuiltins.currentSystem\fR\fR for the \fCsystem\fR argument. You can override this using \fC--arg\fR, e.g., \fCnix-env --install --attr pkgname --arg system \e\(dqi686-freebsd\e\(dq\fR. (Note that since the argument is a Nix string literal, you have to escape the quotes.) .IP "\(bu" 3 \fB\fC--argstr\fR\fR \fIname\fR \fIvalue\fR .IP This option is like \fC--arg\fR, only the value is not a Nix expression but a string. So instead of \fC--arg system \e\(dqi686-linux\e\(dq\fR (the outer quotes are to keep the shell happy) you can say \fC--argstr system i686-linux\fR. .IP "\(bu" 3 \fB\fC--attr\fR\fR / \fC-A\fR \fIattrPath\fR .IP Select an attribute from the top-level Nix expression being evaluated. (\fCnix-env\fR, \fCnix-instantiate\fR, \fCnix-build\fR and \fCnix-shell\fR only.) The \fIattribute path\fR \fIattrPath\fR is a sequence of attribute names separated by dots. For instance, given a top-level Nix expression \fIe\fR, the attribute path \fCxorg.xorgserver\fR would cause the expression \fCe.xorg.xorgserver\fR to be used. See \fB\fCnix-env --install\fR\fR for some concrete examples. .IP In addition to attribute names, you can also specify array indices. For instance, the attribute path \fCfoo.3.bar\fR selects the \fCbar\fR attribute of the fourth element of the array in the \fCfoo\fR attribute of the top-level expression. .IP "\(bu" 3 \fB\fC--expr\fR\fR / \fC-E\fR .IP Interpret the command line arguments as a list of Nix expressions to be parsed and evaluated, rather than as a list of file names of Nix expressions. (\fCnix-instantiate\fR, \fCnix-build\fR and \fCnix-shell\fR only.) .IP For \fCnix-shell\fR, this option is commonly used to give you a shell in which you can build the packages returned by the expression. If you want to get a shell which contain the \fIbuilt\fR packages ready for use, give your expression to the \fCnix-shell --packages\fR convenience flag instead. .IP "\(bu" 3 \fB\fC-I\fR\fR \fIpath\fR .IP Add an entry to the \fBNix expression search path\fR. This option may be given multiple times. Paths added through \fC-I\fR take precedence over \fB\fCNIX_PATH\fR\fR. .IP "\(bu" 3 \fB\fC--option\fR\fR \fIname\fR \fIvalue\fR .IP Set the Nix configuration option \fIname\fR to \fIvalue\fR. This overrides settings in the Nix configuration file (see nix.conf5). .IP "\(bu" 3 \fB\fC--repair\fR\fR .IP Fix corrupted or missing store paths by redownloading or rebuilding them. Note that this is slow because it requires computing a cryptographic hash of the contents of every path in the closure of the build. Also note the warning under \fCnix-store --repair-path\fR. .RS .LP \fBNote\fR .PP See \fB\fCman nix.conf\fR\fR for overriding configuration settings with command line flags. .RE .SH Environment variables .IP "\(bu" 3 \fCNIX_PROFILE\fR .br Location of the Nix profile. Defaults to the target of the symlink \fC\(ti/.nix-profile\fR, if it exists, or \fC/nix/var/nix/profiles/default\fR otherwise. .SH Common Environment Variables .LP Most Nix commands interpret the following environment variables: .IP "\(bu" 3 \fB\fCIN_NIX_SHELL\fR\fR .IP Indicator that tells if the current environment was set up by \fCnix-shell\fR. It can have the values \fCpure\fR or \fCimpure\fR. .IP "\(bu" 3 \fB\fCNIX_PATH\fR\fR .IP A colon-separated list of directories used to look up the location of Nix expressions using \fBpaths\fR enclosed in angle brackets (i.e., \fC\fR), e.g. \fC/home/eelco/Dev:/etc/nixos\fR. It can be extended using the \fB\fC-I\fR option\fR. .IP If \fCNIX_PATH\fR is not set at all, Nix will fall back to the following list in \fBimpure\fR and \fBunrestricted\fR evaluation mode: .RS .IP "1." 3 \fC$HOME/.nix-defexpr/channels\fR .if n \ .sp -1 .if t \ .sp -0.25v .IP "2." 3 \fCnixpkgs=/nix/var/nix/profiles/per-user/root/channels/nixpkgs\fR .if n \ .sp -1 .if t \ .sp -0.25v .IP "3." 3 \fC/nix/var/nix/profiles/per-user/root/channels\fR .RE .IP If \fCNIX_PATH\fR is set to an empty string, resolving search paths will always fail. For example, attempting to use \fC\fR will produce: .IP error: file \(oqnixpkgs\(cq was not found in the Nix search path .IP "\(bu" 3 \fB\fCNIX_IGNORE_SYMLINK_STORE\fR\fR .IP Normally, the Nix store directory (typically \fC/nix/store\fR) is not allowed to contain any symlink components. This is to prevent “impure” builds. Builders sometimes “canonicalise” paths by resolving all symlink components. Thus, builds on different machines (with \fC/nix/store\fR resolving to different locations) could yield different results. This is generally not a problem, except when builds are deployed to machines where \fC/nix/store\fR resolves differently. If you are sure that you’re not going to do that, you can set \fCNIX_IGNORE_SYMLINK_STORE\fR to \fC1\fR. .IP Note that if you’re symlinking the Nix store so that you can put it on another file system than the root file system, on Linux you’re better off using \fCbind\fR mount points, e.g., .LP .EX $ mkdir /nix $ mount -o bind /mnt/otherdisk/nix /nix .EE .IP Consult the mount 8 manual page for details. .IP "\(bu" 3 \fB\fCNIX_STORE_DIR\fR\fR .IP Overrides the location of the Nix store (default \fCprefix/store\fR). .IP "\(bu" 3 \fB\fCNIX_DATA_DIR\fR\fR .IP Overrides the location of the Nix static data directory (default \fCprefix/share\fR). .IP "\(bu" 3 \fB\fCNIX_LOG_DIR\fR\fR .IP Overrides the location of the Nix log directory (default \fCprefix/var/log/nix\fR). .IP "\(bu" 3 \fB\fCNIX_STATE_DIR\fR\fR .IP Overrides the location of the Nix state directory (default \fCprefix/var/nix\fR). .IP "\(bu" 3 \fB\fCNIX_CONF_DIR\fR\fR .IP Overrides the location of the system Nix configuration directory (default \fCprefix/etc/nix\fR). .IP "\(bu" 3 \fB\fCNIX_CONFIG\fR\fR .IP Applies settings from Nix configuration from the environment. The content is treated as if it was read from a Nix configuration file. Settings are separated by the newline character. .IP "\(bu" 3 \fB\fCNIX_USER_CONF_FILES\fR\fR .IP Overrides the location of the Nix user configuration files to load from. .IP The default are the locations according to the \fBXDG Base Directory Specification\fR. See the \fBXDG Base Directories\fR sub-section for details. .IP The variable is treated as a list separated by the \fC:\fR token. .IP "\(bu" 3 \fB\fCTMPDIR\fR\fR .IP Use the specified directory to store temporary files. In particular, this includes temporary build directories; these can take up substantial amounts of disk space. The default is \fC/tmp\fR. .IP "\(bu" 3 \fB\fCNIX_REMOTE\fR\fR .IP This variable should be set to \fCdaemon\fR if you want to use the Nix daemon to execute Nix operations. This is necessary in \fBmulti-user Nix installations\fR. If the Nix daemon\(cqs Unix socket is at some non-standard path, this variable should be set to \fCunix://path/to/socket\fR. Otherwise, it should be left unset. .IP "\(bu" 3 \fB\fCNIX_SHOW_STATS\fR\fR .IP If set to \fC1\fR, Nix will print some evaluation statistics, such as the number of values allocated. .IP "\(bu" 3 \fB\fCNIX_COUNT_CALLS\fR\fR .IP If set to \fC1\fR, Nix will print how often functions were called during Nix expression evaluation. This is useful for profiling your Nix expressions. .IP "\(bu" 3 \fB\fCGC_INITIAL_HEAP_SIZE\fR\fR .IP If Nix has been configured to use the Boehm garbage collector, this variable sets the initial size of the heap in bytes. It defaults to 384 MiB. Setting it to a low value reduces memory consumption, but will increase runtime due to the overhead of garbage collection. .SS XDG Base Directories .LP Nix follows the \fBXDG Base Directory Specification\fR. .PP For backwards compatibility, Nix commands will follow the standard only when \fB\fCuse-xdg-base-directories\fR\fR is enabled. \fBNew Nix commands\fR (experimental) conform to the standard by default. .PP The following environment variables are used to determine locations of various state and configuration files: .IP "\(bu" 3 [\fCXDG_CONFIG_HOME\fR]{#env-XDG\fICONFIG\fRHOME} (default \fC\(ti/.config\fR) .if n \ .sp -1 .if t \ .sp -0.25v .IP "\(bu" 3 [\fCXDG_STATE_HOME\fR]{#env-XDG\fISTATE\fRHOME} (default \fC\(ti/.local/state\fR) .if n \ .sp -1 .if t \ .sp -0.25v .IP "\(bu" 3 [\fCXDG_CACHE_HOME\fR]{#env-XDG\fICACHE\fRHOME} (default \fC\(ti/.cache\fR) .SH Examples .LP To show installed packages: .LP .EX $ nix-env --query bison-1.875c docbook-xml-4.2 firefox-1.0.4 MPlayer-1.0pre7 ORBit2-2.8.3 … .EE .PP To show available packages: .LP .EX $ nix-env --query --available firefox-1.0.7 GConf-2.4.0.1 MPlayer-1.0pre7 ORBit2-2.8.3 … .EE .PP To show the status of available packages: .LP .EX $ nix-env --query --available --status -P- firefox-1.0.7 (not installed but present) --S GConf-2.4.0.1 (not present, but there is a substitute for fast installation) --S MPlayer-1.0pre3 (i.e., this is not the installed MPlayer, even though the version is the same!) IP- ORBit2-2.8.3 (installed and by definition present) … .EE .PP To show available packages in the Nix expression \fCfoo.nix\fR: .LP .EX $ nix-env --file ./foo.nix --query --available foo-1.2.3 .EE .PP To compare installed versions to what’s available: .LP .EX $ nix-env --query --compare-versions \&... acrobat-reader-7.0 - ? (package is not available at all) autoconf-2.59 = 2.59 (same version) firefox-1.0.4 < 1.0.7 (a more recent version is available) \&... .EE .PP To show all packages with “\fCzip\fR” in the name: .LP .EX $ nix-env --query --available '.*zip.*' bzip2-1.0.6 gzip-1.6 zip-3.0 … .EE .PP To show all packages with “\fCfirefox\fR” or “\fCchromium\fR” in the name: .LP .EX $ nix-env --query --available '.*(firefox|chromium).*' chromium-37.0.2062.94 chromium-beta-38.0.2125.24 firefox-32.0.3 firefox-with-plugins-13.0.1 … .EE .PP To show all packages in the latest revision of the Nixpkgs repository: .LP .EX $ nix-env --file https://github.com/NixOS/nixpkgs/archive/master.tar.gz --query --available .EE