Home Explore Blog CI



nix

1st chunk of `doc/manual/source/command-ref/opt-common.md`
99a779f0d85b8570adeda8b0838db75268e4956e4e8b6d060000000100000fdf
<!-- Some of the options documented here are hardcopied from
     src/libcmd/common-eval-args.cc
-->

# Common Options

Most Nix commands accept the following command-line options:

- <span id="opt-help">[`--help`](#opt-help)</span>

  Prints out a summary of the command syntax and exits.

- <span id="opt-version">[`--version`](#opt-version)</span>

  Prints out the Nix version number on standard output and exits.

- <span id="opt-verbose">[`--verbose`](#opt-verbose)</span> / `-v`

  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.

  This option may be specified repeatedly.
  Currently, the following verbosity levels exist:

  - `0` “Errors only”

    Only print messages explaining why the Nix invocation failed.

  - `1` “Informational”

    Print *useful* messages about what Nix is doing.
    This is the default.

  - `2` “Talkative”

    Print more informational messages.

  - `3` “Chatty”

    Print even more informational messages.

  - `4` “Debug”

    Print debug information.

  - `5` “Vomit”

    Print vast amounts of debug information.

- <span id="opt-quiet">[`--quiet`](#opt-quiet)</span>

  Decreases the level of verbosity of diagnostic messages printed on standard error.
  This is the inverse option to `-v` / `--verbose`.

  This option may be specified repeatedly.
  See the previous verbosity levels list.

- <span id="opt-log-format">[`--log-format`](#opt-log-format)</span> *format*

  This option can be used to change the output of the log format, with *format* being one of:

  - `raw`

    This is the raw format, as outputted by nix-build.

  - `internal-json`

    Outputs the logs in a structured manner.

    > **Warning**
    >
    > While the schema itself is relatively stable, the format of
    > the error-messages (namely of the `msg`-field) can change
    > between releases.

  - `bar`

    Only display a progress bar during the builds.

  - `bar-with-logs`

    Display the raw logs, with the progress bar at the bottom.

- <span id="opt-no-build-output">[`--no-build-output`](#opt-no-build-output)</span> / `-Q`

  By default, output written by builders to standard output and standard error is echoed to the Nix command's standard error.
  This option suppresses this behaviour.
  Note that the builder's standard output and error are always written to a log file in `prefix/nix/var/log/nix`.

- <span id="opt-max-jobs">[`--max-jobs`](#opt-max-jobs)</span> / `-j` *number*

  Sets the maximum number of build jobs that Nix will perform in parallel to the specified number.
  Specify `auto` to use the number of CPUs in the system.
  The default is specified by the `max-jobs` configuration setting, which itself defaults to `1`.
  A higher value is useful on SMP systems or to exploit I/O latency.

  Setting it to `0` disallows building on the local machine, which is useful when you want builds to happen only on remote builders.

- <span id="opt-cores">[`--cores`](#opt-cores)</span>

  Sets the value of the `NIX_BUILD_CORES` 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 `enableParallelBuilding` is set to `true`, the builder passes the `-jN` flag to GNU Make.
  It defaults to the value of the `cores` configuration setting, if set, or `1` otherwise.
  The value `0` means that the builder should use all available CPU cores in the system.

- <span id="opt-max-silent-time">[`--max-silent-time`](#opt-max-silent-time)</span>

  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 `max-silent-time` configuration setting.
  `0` means no time-out.

- <span id="opt-timeout">[`--timeout`](#opt-timeout)</span>

Title: Common Nix Command Options
Summary
This section details common command-line options available for most Nix commands. These include options for displaying help and version information, controlling verbosity, setting the log format, suppressing build output, limiting the number of parallel build jobs, configuring the NIX_BUILD_CORES environment variable for builders, and setting a timeout for builder silence.