Home Explore Blog CI



nix

4th chunk of `doc/manual/source/command-ref/opt-common.md`
4af1df0c425fa793dafbdb27198559ae921cc530554db79f0000000100000d95
- <span id="opt-arg-from-file">[`--arg-from-file`](#opt-arg-from-file)</span> *name* *path*

  Pass the contents of file *path* as the argument *name* to Nix functions.

- <span id="opt-arg-from-stdin">[`--arg-from-stdin`](#opt-arg-from-stdin)</span> *name*

  Pass the contents of stdin as the argument *name* to Nix functions.

- <span id="opt-argstr">[`--argstr`](#opt-argstr)</span> *name* *value*

  This option is like `--arg`, only the value is not a Nix expression but a string.
  So instead of `--arg system \"i686-linux\"` (the outer quotes are to keep the shell happy) you can say `--argstr system i686-linux`.

- <span id="opt-attr">[`--attr`](#opt-attr)</span> / `-A` *attrPath*

  Select an attribute from the top-level Nix expression being evaluated.
  (`nix-env`, `nix-instantiate`, `nix-build` and `nix-shell` only.)
  The *attribute path* *attrPath* is a sequence of attribute names separated by dots.
  For instance, given a top-level Nix expression *e*, the attribute path `xorg.xorgserver` would cause the expression `e.xorg.xorgserver` to be used.
  See [`nix-env --install`](@docroot@/command-ref/nix-env/install.md) for some concrete examples.

  In addition to attribute names, you can also specify array indices.
  For instance, the attribute path `foo.3.bar` selects the `bar`
  attribute of the fourth element of the array in the `foo` attribute
  of the top-level expression.

- <span id="opt-eval-store">[`--eval-store`](#opt-eval-store)</span> *store-url*

  The [URL to the Nix store](@docroot@/store/types/index.md#store-url-format) to use for evaluation, i.e. where to store derivations (`.drv` files) and inputs referenced by them.

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

  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.
  (`nix-instantiate`, `nix-build` and `nix-shell` only.)

  For `nix-shell`, 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 *built* packages ready for use, give your expression to the `nix-shell --packages ` convenience flag instead.

- <span id="opt-I">[`-I` / `--include`](#opt-I)</span> *path*

  Add an entry to the list of search paths used to resolve [lookup paths](@docroot@/language/constructs/lookup-path.md).
  This option may be given multiple times.

  Paths added through `-I` take precedence over the [`nix-path` configuration setting](@docroot@/command-ref/conf-file.md#conf-nix-path) and the [`NIX_PATH` environment variable](@docroot@/command-ref/env-common.md#env-NIX_PATH).

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

  Allow access to mutable paths and repositories.

- <span id="opt-option">[`--option`](#opt-option)</span> *name* *value*

  Set the Nix configuration option *name* to *value*.
  This overrides settings in the Nix configuration file (see nix.conf5).

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

  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 `nix-store --repair-path`.

> **Note**
>
> See [`man nix.conf`](@docroot@/command-ref/conf-file.md#command-line-flags) for overriding configuration settings with command line flags.

Title: Nix Command Options: Argument Passing, Attribute Selection, and Environment Configuration
Summary
This section continues detailing Nix command-line options, including methods for passing arguments to Nix functions from files or standard input (`--arg-from-file`, `--arg-from-stdin`, `--argstr`), selecting attributes from expressions (`--attr`), specifying the store URL for evaluation (`--eval-store`), interpreting arguments as expressions (`--expr`), adding search paths for lookup paths (`-I` / `--include`), allowing impure operations (`--impure`), setting Nix configuration options (`--option`), and repairing corrupted store paths (`--repair`).