Home Explore Blog CI



nixpkgs

14th chunk of `doc/stdenv/stdenv.chapter.md`
2486b740a5c23b5b00cf1889bcdb25a6f02a6be664b273830000000100001022
A shell array containing additional arguments passed to the configure script. You must use this instead of `configureFlags` if the arguments contain spaces.

##### `dontAddPrefix` {#var-stdenv-dontAddPrefix}

By default, `./configure` is passed the concatenation of [`prefixKey`](#var-stdenv-prefixKey) and [`prefix`](#var-stdenv-prefix) on the command line. Disable this by setting `dontAddPrefix` to `true`.

##### `prefix` {#var-stdenv-prefix}

The prefix under which the package must be installed, passed via the `--prefix` option to the configure script. It defaults to `$out`.

##### `prefixKey` {#var-stdenv-prefixKey}

The key to use when specifying the installation [`prefix`](#var-stdenv-prefix). By default, this is set to `--prefix=` as that is used by the majority of packages. Other packages may need `--prefix ` (with a trailing space) or `PREFIX=`.

##### `dontAddStaticConfigureFlags` {#var-stdenv-dontAddStaticConfigureFlags}

By default, when building statically, stdenv will try to add build system appropriate configure flags to try to enable static builds.

If this is undesirable, set this variable to true.

##### `dontAddDisableDepTrack` {#var-stdenv-dontAddDisableDepTrack}

By default, the flag `--disable-dependency-tracking` is added to the configure flags to speed up Automake-based builds. If this is undesirable, set this variable to true.

##### `dontFixLibtool` {#var-stdenv-dontFixLibtool}

By default, the configure phase applies some special hackery to all files called `ltmain.sh` before running the configure script in order to improve the purity of Libtool-based packages [^footnote-stdenv-sys-lib-search-path] . If this is undesirable, set this variable to true.

##### `dontDisableStatic` {#var-stdenv-dontDisableStatic}

By default, when the configure script has `--enable-static`, the option `--disable-static` is added to the configure flags.

If this is undesirable, set this variable to true.  It is automatically set to true when building statically, for example through `pkgsStatic`.

##### `configurePlatforms` {#var-stdenv-configurePlatforms}

By default, when cross compiling, the configure script has `--build=...` and `--host=...` passed. Packages can instead pass `[ "build" "host" "target" ]` or a subset to control exactly which platform flags are passed. Compilers and other tools can use this to also pass the target platform. [^footnote-stdenv-build-time-guessing-impurity]

##### `preConfigure` {#var-stdenv-preConfigure}

Hook executed at the start of the configure phase.

##### `postConfigure` {#var-stdenv-postConfigure}

Hook executed at the end of the configure phase.

### The build phase {#build-phase}

The build phase is responsible for actually building the package (e.g. compiling it). The default `buildPhase` calls `make` if a file named `Makefile`, `makefile` or `GNUmakefile` exists in the current directory (or the `makefile` is explicitly set); otherwise it does nothing.

#### Variables controlling the build phase {#variables-controlling-the-build-phase}

##### `dontBuild` {#var-stdenv-dontBuild}

Set to true to skip the build phase.

##### `makefile` {#var-stdenv-makefile}

The file name of the Makefile.

##### `makeFlags` {#var-stdenv-makeFlags}

A list of strings passed as additional flags to `make`. These flags are also used by the default install and check phase. For setting make flags specific to the build phase, use `buildFlags` (see below).

```nix
{
  makeFlags = [ "PREFIX=$(out)" ];
}
```

::: {.note}
The flags are quoted in bash, but environment variables can be specified by using the make syntax.
:::

##### `makeFlagsArray` {#var-stdenv-makeFlagsArray}

A shell array containing additional arguments passed to `make`. You must use this instead of `makeFlags` if the arguments contain spaces, e.g.

```nix
{
  preBuild = ''
    makeFlagsArray+=(CFLAGS="-O0 -g" LDFLAGS="-lfoo -lbar")
  '';
}
```

Note that shell arrays cannot be passed through environment variables, so you cannot set `makeFlagsArray` in a derivation attribute (because those are passed through environment variables): you have to define them in shell code.

Title: Configure and Build Phase Variables in Nix Builds
Summary
This section details various variables that control the configure and build phases in Nix builds. For the configure phase, it covers variables like `dontAddDisableDepTrack`, `dontFixLibtool`, `dontDisableStatic`, `configurePlatforms`, `preConfigure`, and `postConfigure`. For the build phase, it describes `dontBuild`, `makefile`, `makeFlags`, and `makeFlagsArray`, explaining their purpose and usage.