Home Explore Blog Models CI



nixpkgs

20th chunk of `doc/stdenv/stdenv.chapter.md`
cdcefb1a20a67d74c24187ae77b6e01c8ba066f5bce3ae580000000100000feb
##### `installCheckTarget` {#var-stdenv-installCheckTarget}

The make target that runs the install tests. Defaults to `installcheck`.

##### `installCheckFlags` / `installCheckFlagsArray` {#var-stdenv-installCheckFlags}

A list of strings passed as additional flags to `make`. Like `makeFlags` and `makeFlagsArray`, but only used by the installCheck phase.

##### `installCheckInputs` {#var-stdenv-installCheckInputs}

A list of host dependencies used by the phase, usually libraries linked into executables built during tests. This gets included in `buildInputs` when `doInstallCheck` is set.

##### `nativeInstallCheckInputs` {#var-stdenv-nativeInstallCheckInputs}

A list of native dependencies used by the phase, notably tools needed on `$PATH`. This gets included in `nativeBuildInputs` when `doInstallCheck` is set.

##### `preInstallCheck` {#var-stdenv-preInstallCheck}

Hook executed at the start of the installCheck phase.

##### `postInstallCheck` {#var-stdenv-postInstallCheck}

Hook executed at the end of the installCheck phase.

### The distribution phase {#ssec-distribution-phase}

The distribution phase is intended to produce a source distribution of the package. The default `distPhase` first calls `make dist`, then it copies the resulting source tarballs to `$out/tarballs/`. This phase is only executed if the attribute `doDist` is set.

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

##### `doDist` {#var-stdenv-doDist}

If set, the distribution phase is executed.

##### `distTarget` {#var-stdenv-distTarget}

The make target that produces the distribution. Defaults to `dist`.

##### `distFlags` / `distFlagsArray` {#var-stdenv-distFlags}

Additional flags passed to `make`.

##### `tarballs` {#var-stdenv-tarballs}

The names of the source distribution files to be copied to `$out/tarballs/`. It can contain shell wildcards. The default is `*.tar.gz`.

##### `dontCopyDist` {#var-stdenv-dontCopyDist}

If set, no files are copied to `$out/tarballs/`.

##### `preDist` {#var-stdenv-preDist}

Hook executed at the start of the distribution phase.

##### `postDist` {#var-stdenv-postDist}

Hook executed at the end of the distribution phase.

## Shell functions and utilities {#ssec-stdenv-functions}

The standard environment provides a number of useful functions.

### `makeWrapper` \<executable\> \<wrapperfile\> \<args\> {#fun-makeWrapper}

Constructs a wrapper for a program with various possible arguments. It is defined as part of 2 setup-hooks named `makeWrapper` and `makeBinaryWrapper` that implement the same bash functions. Hence, to use it you have to add `makeWrapper` to your `nativeBuildInputs`. Here's an example usage:

```bash
# adds `FOOBAR=baz` to `$out/bin/foo`’s environment
makeWrapper $out/bin/foo $wrapperfile --set FOOBAR baz

# Prefixes the binary paths of `hello` and `git`
# and suffixes the binary path of `xdg-utils`.
# Be advised that paths often should be patched in directly
# (via string replacements or in `configurePhase`).
makeWrapper $out/bin/foo $wrapperfile \
  --prefix PATH : ${lib.makeBinPath [ hello git ]} \
  --suffix PATH : ${lib.makeBinPath [ xdg-utils ]}
```

Packages may expect or require other utilities to be available at runtime.
`makeWrapper` can be used to add packages to a `PATH` environment variable local to a wrapper.

Use `--prefix` to explicitly set dependencies in `PATH`.

::: {.note}
`--prefix` essentially hard-codes dependencies into the wrapper.
They cannot be overridden without rebuilding the package.
:::

If dependencies should be resolved at runtime, use `--suffix` to append fallback values to `PATH`.

There’s many more kinds of arguments, they are documented in `nixpkgs/pkgs/build-support/setup-hooks/make-wrapper.sh` for the `makeWrapper` implementation and in `nixpkgs/pkgs/by-name/ma/makeBinaryWrapper/make-binary-wrapper.sh` for the `makeBinaryWrapper` implementation.

`wrapProgram` is a convenience function you probably want to use most of the time, implemented by both `makeWrapper` and `makeBinaryWrapper`.

Title: Nix Build Phases: InstallCheck, Distribution, and Program Wrapping with `makeWrapper`
Summary
This chunk details variables controlling the `installCheck` phase in Nix, including `installCheckTarget` (default `installcheck`), `installCheckFlags` for additional `make` flags, and `installCheckInputs`/`nativeInstallCheckInputs` for dependencies, along with `preInstallCheck` and `postInstallCheck` hooks. It then introduces the `distribution` phase, intended to produce source tarballs by calling `make dist` and copying them to `$out/tarballs/`. This phase is activated by `doDist` and controlled by variables like `distTarget`, `distFlags`, `tarballs` (default `*.tar.gz`), `dontCopyDist`, and `preDist`/`postDist` hooks. Finally, it describes `makeWrapper`, a utility requiring `makeWrapper` in `nativeBuildInputs`, used to create program wrappers and customize their environment variables, such as setting values with `--set` or modifying `PATH` using `--prefix` for hard-coded dependencies or `--suffix` for fallback values. `wrapProgram` is mentioned as a convenience function.