Home Explore Blog Models CI



nixpkgs

14th chunk of `doc/stdenv/stdenv.chapter.md`
bfce62aa75f5e6548cd1c84f4ec2ddab73bd9c313ea79b770000000100000fac
If set to `1`, the unpacked sources are *not* made writable. By default, they are made writable to prevent problems with read-only sources. For example, copied store directories would be read-only without this.

##### `unpackCmd` {#var-stdenv-unpackCmd}

The unpack phase evaluates the string `$unpackCmd` for any unrecognised file. The path to the current source file is contained in the `curSrc` variable.

### The patch phase {#ssec-patch-phase}

The patch phase applies the list of patches defined in the `patches` variable.

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

##### `dontPatch` {#var-stdenv-dontPatch}

Set to true to skip the patch phase.

##### `patches` {#var-stdenv-patches}

The list of patches. They must be in the format accepted by the `patch` command, and may optionally be compressed using `gzip` (`.gz`), `bzip2` (`.bz2`) or `xz` (`.xz`).

##### `patchFlags` {#var-stdenv-patchFlags}

Flags to be passed to `patch`. If not set, the argument `-p1` is used, which causes the leading directory component to be stripped from the file names in each patch.

##### `prePatch` {#var-stdenv-prePatch}

Hook executed at the start of the patch phase.

##### `postPatch` {#var-stdenv-postPatch}

Hook executed at the end of the patch phase.

### The configure phase {#ssec-configure-phase}

The configure phase prepares the source tree for building. The default `configurePhase` runs `./configure` (typically an Autoconf-generated script) if it exists.

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

##### `configureScript` {#var-stdenv-configureScript}

The name of the configure script. It defaults to `./configure` if it exists; otherwise, the configure phase is skipped. This can actually be a command (like `perl ./Configure.pl`).

##### `configureFlags` {#var-stdenv-configureFlags}

A list of strings passed as additional arguments to the configure script.

##### `dontConfigure` {#var-stdenv-dontConfigure}

Set to true to skip the configure phase.

##### `configureFlagsArray` {#var-stdenv-configureFlagsArray}

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.

Title: Nix `stdenv` Patch and Configure Phases and Customization
Summary
This document outlines the `patchPhase` and `configurePhase` in the Nix `stdenv` build system, including their customization options. The `patchPhase` applies specified patches, managed by `dontPatch` (skip), `patches` (list of files, possibly compressed), `patchFlags` (arguments, default `-p1`), and `prePatch`/`postPatch` hooks. The `configurePhase` prepares the source for building, usually by running `./configure`. Its variables include `configureScript` (script/command), `configureFlags` (or `configureFlagsArray` for arguments with spaces), and `dontConfigure` (skip). Additional controls cover disabling automatic prefix addition (`dontAddPrefix`, configured by `prefix` and `prefixKey`), static build flags (`dontAddStaticConfigureFlags`), `--disable-dependency-tracking` (`dontAddDisableDepTrack`), Libtool purity fixes (`dontFixLibtool`), and `--disable-static` (`dontDisableStatic`).