.\" -*- mode: troff; coding: utf-8 -*- .TH "nix-env \(enset-flag" "1" "" .SH Name .LP \f(CRnix-env --set-flag\fR - modify meta attributes of installed packages .SH Synopsis .LP \f(CRnix-env\fR \f(CR--set-flag\fR \fIname\fR \fIvalue\fR \fIdrvnames\fR .SH Description .LP The \f(CR--set-flag\fR operation allows meta attributes of installed packages to be modified. There are several attributes that can be usefully modified, because they affect the behaviour of \f(CRnix-env\fR or the user environment build script: .IP "\(bu" 3 \f(CRpriority\fR can be changed to resolve filename clashes. The user environment build script uses the \f(CRmeta.priority\fR attribute of derivations to resolve filename collisions between packages. Lower priority values denote a higher priority. For instance, the GCC wrapper package and the Binutils package in Nixpkgs both have a file \f(CRbin/ld\fR, so previously if you tried to install both you would get a collision. Now, on the other hand, the GCC wrapper declares a higher priority than Binutils, so the former’s \f(CRbin/ld\fR is symlinked in the user environment. .IP "\(bu" 3 \f(CRkeep\fR can be set to \f(CRtrue\fR to prevent the package from being upgraded or replaced. This is useful if you want to hang on to an older version of a package. .IP "\(bu" 3 \f(CRactive\fR can be set to \f(CRfalse\fR to “disable” the package. That is, no symlinks will be generated to the files of the package, but it remains part of the profile (so it won’t be garbage-collected). It can be set back to \f(CRtrue\fR to re-enable the package. .SH Options .LP The following options are allowed for all \f(CRnix-env\fR operations, but may not always have an effect. .IP "\(bu" 3 \f(CR--file\fR / \f(CR-f\fR \fIpath\fR .IP Specifies the Nix expression (designated below as the \fIactive Nix expression\fR) used by the \f(CR--install\fR, \f(CR--upgrade\fR, and \f(CR--query --available\fR operations to obtain derivations. The default is \f(CR\(ti/.nix-defexpr\fR. .IP If the argument starts with \f(CRhttp://\fR or \f(CRhttps://\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 \f(CRdefault.nix\fR. .IP "\(bu" 3 \f(CR--profile\fR / \f(CR-p\fR \fIpath\fR .IP 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 \f(CR--dry-run\fR .IP For the \f(CR--install\fR, \f(CR--upgrade\fR, \f(CR--uninstall\fR, \f(CR--switch-generation\fR, \f(CR--delete-generations\fR and \f(CR--rollback\fR operations, this flag will cause \f(CRnix-env\fR to print what \fIwould\fR be done if this flag had not been specified, without actually doing it. .IP \f(CR--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 \f(CR--system-filter\fR \fIsystem\fR .IP By default, operations such as \f(CR--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\f(CR--help\fR\fR .IP Prints out a summary of the command syntax and exits. .IP "\(bu" 3 \fB\f(CR--version\fR\fR .IP Prints out the Nix version number on standard output and exits. .IP "\(bu" 3 \fB\f(CR--verbose\fR\fR / \f(CR-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 \f(CR0\fR “Errors only” .RE .IP Only print messages explaining why the Nix invocation failed. .RS .IP "\(bu" 3 \f(CR1\fR “Informational” .RE .IP Print \fIuseful\fR messages about what Nix is doing. This is the default. .RS .IP "\(bu" 3 \f(CR2\fR “Talkative” .RE .IP Print more informational messages. .RS .IP "\(bu" 3 \f(CR3\fR “Chatty” .RE .IP Print even more informational messages. .RS .IP "\(bu" 3 \f(CR4\fR “Debug” .RE .IP Print debug information. .RS .IP "\(bu" 3 \f(CR5\fR “Vomit” .RE .IP Print vast amounts of debug information. .IP "\(bu" 3 \fB\f(CR--quiet\fR\fR .IP Decreases the level of verbosity of diagnostic messages printed on standard error. This is the inverse option to \f(CR-v\fR / \f(CR--verbose\fR. .IP This option may be specified repeatedly. See the previous verbosity levels list. .IP "\(bu" 3 \fB\f(CR--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 \f(CRraw\fR .RE .IP This is the raw format, as outputted by nix-build. .RS .IP "\(bu" 3 \f(CRinternal-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 \f(CRmsg\fR-field) can change between releases. .RE .RS .IP "\(bu" 3 \f(CRbar\fR .RE .IP Only display a progress bar during the builds. .RS .IP "\(bu" 3 \f(CRbar-with-logs\fR .RE .IP Display the raw logs, with the progress bar at the bottom. .IP "\(bu" 3 \fB\f(CR--no-build-output\fR\fR / \f(CR-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 \f(CRprefix/nix/var/log/nix\fR. .IP "\(bu" 3 \fB\f(CR--max-jobs\fR\fR / \f(CR-j\fR \fInumber\fR .IP Sets the maximum number of build jobs that Nix will perform in parallel to the specified number. Specify \f(CRauto\fR to use the number of CPUs in the system. The default is specified by the \f(CRmax-jobs\fR configuration setting, which itself defaults to \f(CR1\fR. A higher value is useful on SMP systems or to exploit I/O latency. .IP Setting it to \f(CR0\fR disallows building on the local machine, which is useful when you want builds to happen only on remote builders. .IP "\(bu" 3 \fB\f(CR--cores\fR\fR .IP Sets the value of the \f(CRNIX_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 \f(CRenableParallelBuilding\fR is set to \f(CRtrue\fR, the builder passes the \f(CR-jN\fR flag to GNU Make. It defaults to the value of the \f(CRcores\fR configuration setting, if set, or \f(CR1\fR otherwise. The value \f(CR0\fR means that the builder should use all available CPU cores in the system. .IP "\(bu" 3 \fB\f(CR--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 \f(CRmax-silent-time\fR configuration setting. \f(CR0\fR means no time-out. .IP "\(bu" 3 \fB\f(CR--timeout\fR\fR .IP Sets the maximum number of seconds that a builder can run. The default is specified by the \f(CRtimeout\fR configuration setting. \f(CR0\fR means no timeout. .IP "\(bu" 3 \fB\f(CR--keep-going\fR\fR / \f(CR-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\f(CR--keep-failed\fR\fR / \f(CR-K\fR .IP Specifies that in case of a build failure, the temporary directory (usually in \f(CR/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\f(CR--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\f(CR--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\f(CR--arg\fR\fR \fIname\fR \fIvalue\fR .IP This option is accepted by \f(CRnix-env\fR, \f(CRnix-instantiate\fR, \f(CRnix-shell\fR and \f(CRnix-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., \f(CR{ argName ? defaultValue }: ...\fR). .IP With \f(CR--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 \f(CRdefault.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 \f(CRnix-env --install --attr pkgname\fR), the function will be called automatically using the value \fB\f(CRbuiltins.currentSystem\fR\fR for the \f(CRsystem\fR argument. You can override this using \f(CR--arg\fR, e.g., \f(CRnix-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\f(CR--argstr\fR\fR \fIname\fR \fIvalue\fR .IP This option is like \f(CR--arg\fR, only the value is not a Nix expression but a string. So instead of \f(CR--arg system \e\(dqi686-linux\e\(dq\fR (the outer quotes are to keep the shell happy) you can say \f(CR--argstr system i686-linux\fR. .IP "\(bu" 3 \fB\f(CR--attr\fR\fR / \f(CR-A\fR \fIattrPath\fR .IP Select an attribute from the top-level Nix expression being evaluated. (\f(CRnix-env\fR, \f(CRnix-instantiate\fR, \f(CRnix-build\fR and \f(CRnix-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 \f(CRxorg.xorgserver\fR would cause the expression \f(CRe.xorg.xorgserver\fR to be used. See \fB\f(CRnix-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 \f(CRfoo.3.bar\fR selects the \f(CRbar\fR attribute of the fourth element of the array in the \f(CRfoo\fR attribute of the top-level expression. .IP "\(bu" 3 \fB\f(CR--expr\fR\fR / \f(CR-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. (\f(CRnix-instantiate\fR, \f(CRnix-build\fR and \f(CRnix-shell\fR only.) .IP For \f(CRnix-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 \f(CRnix-shell --packages\fR convenience flag instead. .IP "\(bu" 3 \fB\f(CR-I\fR / \f(CR--include\fR\fR \fIpath\fR .IP Add an entry to the list of search paths used to resolve \fBlookup paths\fR. This option may be given multiple times. .IP Paths added through \f(CR-I\fR take precedence over the \fB\f(CRnix-path\fR configuration setting\fR and the \fB\f(CRNIX_PATH\fR environment variable\fR. .IP "\(bu" 3 \fB\f(CR--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\f(CR--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 \f(CRnix-store --repair-path\fR. .RS .LP \fBNote\fR .PP See \fB\f(CRman nix.conf\fR\fR for overriding configuration settings with command line flags. .RE .SH Common Environment Variables .LP Most Nix commands interpret the following environment variables: .IP "\(bu" 3 \fB\f(CRIN_NIX_SHELL\fR\fR .IP Indicator that tells if the current environment was set up by \f(CRnix-shell\fR. It can have the values \f(CRpure\fR or \f(CRimpure\fR. .IP "\(bu" 3 \fB\f(CRNIX_PATH\fR\fR .IP A colon-separated list of search path entries used to resolve \fBlookup paths\fR. .IP This environment variable overrides the value of the \fB\f(CRnix-path\fR configuration setting\fR. .IP It can be extended using the \fB\f(CR-I\fR option\fR. .RS .IP \fBExample\fR .LP .EX $ export NIX_PATH=\(ga/home/eelco/Dev:nixos-config=/etc/nixos .EE .RE .IP If \f(CRNIX_PATH\fR is set to an empty string, resolving search paths will always fail. .RS .IP \fBExample\fR .LP .EX $ NIX_PATH= nix-instantiate --eval '' error: file 'nixpkgs' was not found in the Nix search path (add it using $NIX_PATH or -I) .EE .RE .IP "\(bu" 3 \fB\f(CRNIX_IGNORE_SYMLINK_STORE\fR\fR .IP Normally, the Nix store directory (typically \f(CR/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 \f(CR/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 \f(CR/nix/store\fR resolves differently. If you are sure that you’re not going to do that, you can set \f(CRNIX_IGNORE_SYMLINK_STORE\fR to \f(CR1\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 \f(CRbind\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\f(CRNIX_STORE_DIR\fR\fR .IP Overrides the location of the Nix store (default \f(CRprefix/store\fR). .IP "\(bu" 3 \fB\f(CRNIX_DATA_DIR\fR\fR .IP Overrides the location of the Nix static data directory (default \f(CRprefix/share\fR). .IP "\(bu" 3 \fB\f(CRNIX_LOG_DIR\fR\fR .IP Overrides the location of the Nix log directory (default \f(CRprefix/var/log/nix\fR). .IP "\(bu" 3 \fB\f(CRNIX_STATE_DIR\fR\fR .IP Overrides the location of the Nix state directory (default \f(CRprefix/var/nix\fR). .IP "\(bu" 3 \fB\f(CRNIX_CONF_DIR\fR\fR .IP Overrides the location of the system Nix configuration directory (default \f(CRprefix/etc/nix\fR). .IP "\(bu" 3 \fB\f(CRNIX_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\f(CRNIX_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 \f(CR:\fR token. .IP "\(bu" 3 \fB\f(CRTMPDIR\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 \f(CR/tmp\fR. .IP "\(bu" 3 \fB\f(CRNIX_REMOTE\fR\fR .IP This variable should be set to \f(CRdaemon\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 \f(CRunix://path/to/socket\fR. Otherwise, it should be left unset. .IP "\(bu" 3 \fB\f(CRNIX_SHOW_STATS\fR\fR .IP If set to \f(CR1\fR, Nix will print some evaluation statistics, such as the number of values allocated. .IP "\(bu" 3 \fB\f(CRNIX_COUNT_CALLS\fR\fR .IP If set to \f(CR1\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\f(CRGC_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\f(CRuse-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 [\f(CRXDG_CONFIG_HOME\fR]{#env-XDG\fICONFIG\fRHOME} (default \f(CR\(ti/.config\fR) .if n \ .sp -1 .if t \ .sp -0.25v .IP "\(bu" 3 [\f(CRXDG_STATE_HOME\fR]{#env-XDG\fISTATE\fRHOME} (default \f(CR\(ti/.local/state\fR) .if n \ .sp -1 .if t \ .sp -0.25v .IP "\(bu" 3 [\f(CRXDG_CACHE_HOME\fR]{#env-XDG\fICACHE\fRHOME} (default \f(CR\(ti/.cache\fR) .SH Examples .LP To prevent the currently installed Firefox from being upgraded: .LP .EX $ nix-env --set-flag keep true firefox .EE .PP After this, \f(CRnix-env --upgrade\fR will ignore Firefox. .PP To disable the currently installed Firefox, then install a new Firefox while the old remains part of the profile: .LP .EX $ nix-env --query firefox-2.0.0.9 (the current one) $ nix-env --preserve-installed --install firefox-2.0.0.11 installing \(gafirefox-2.0.0.11' building path(s) \(ga/nix/store/myy0y59q3ig70dgq37jqwg1j0rsapzsl-user-environment' collision between \(ga/nix/store/...-firefox-2.0.0.11/bin/firefox' and \(ga/nix/store/...-firefox-2.0.0.9/bin/firefox'. (i.e., can’t have two active at the same time) $ nix-env --set-flag active false firefox setting flag on \(gafirefox-2.0.0.9' $ nix-env --preserve-installed --install firefox-2.0.0.11 installing \(gafirefox-2.0.0.11' $ nix-env --query firefox-2.0.0.11 (the enabled one) firefox-2.0.0.9 (the disabled one) .EE .PP To make files from \f(CRbinutils\fR take precedence over files from \f(CRgcc\fR: .LP .EX $ nix-env --set-flag priority 5 binutils $ nix-env --set-flag priority 10 gcc .EE