Home Explore Blog Models CI



nixpkgs

17th chunk of `doc/stdenv/stdenv.chapter.md`
ff23bcb54eb0eb3d5a0ff154c4d15c6aebb0172572bd78ed0000000100000fd1
The install phase is responsible for installing the package in the Nix store under `out`. The default `installPhase` creates the directory `$out` and calls `make install`.

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

##### `dontInstall` {#var-stdenv-dontInstall}

Set to true to skip the install phase.

##### `makeFlags` / `makeFlagsArray` / `makefile` {#makeflags-makeflagsarray-makefile-1}

See the [build phase](#var-stdenv-makeFlags) for details.

##### `installTargets` {#var-stdenv-installTargets}

The make targets that perform the installation. Defaults to `install`. Example:

```nix
{ installTargets = "install-bin install-doc"; }
```

##### `installFlags` / `installFlagsArray` {#var-stdenv-installFlags}

A list of strings passed as additional flags to `make`. Like `makeFlags` and `makeFlagsArray`, but only used by the install phase. Unlike with `buildFlags`, the `installTargets` are automatically added to the `make` invocation in addition to any `installFlags` specified.

##### `preInstall` {#var-stdenv-preInstall}

Hook executed at the start of the install phase.

##### `postInstall` {#var-stdenv-postInstall}

Hook executed at the end of the install phase.

### The fixup phase {#ssec-fixup-phase}

The fixup phase performs (Nix-specific) post-processing actions on the files installed under `$out` by the install phase. The default `fixupPhase` does the following:

- It moves the `man/`, `doc/` and `info/` subdirectories of `$out` to `share/`.
- It strips libraries and executables of debug information.
- On Linux, it applies the `patchelf` command to ELF executables and libraries to remove unused directories from the `RPATH` in order to prevent unnecessary runtime dependencies.
- It rewrites the interpreter paths of shell scripts to paths found in `PATH`. E.g., `/usr/bin/perl` will be rewritten to `/nix/store/some-perl/bin/perl` found in `PATH`. See [](#patch-shebangs.sh) for details.

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

##### `dontFixup` {#var-stdenv-dontFixup}

Set to true to skip the fixup phase.

##### `dontStrip` {#var-stdenv-dontStrip}

If set, libraries and executables are not stripped. By default, they are.

##### `dontStripHost` {#var-stdenv-dontStripHost}

Like `dontStrip`, but only affects the `strip` command targeting the package’s host platform. Useful when supporting cross compilation, but otherwise feel free to ignore.

##### `dontStripTarget` {#var-stdenv-dontStripTarget}

Like `dontStrip`, but only affects the `strip` command targeting the packages’ target platform. Useful when supporting cross compilation, but otherwise feel free to ignore.

##### `dontMoveSbin` {#var-stdenv-dontMoveSbin}

If set, files in `$out/sbin` are not moved to `$out/bin`. By default, they are.

##### `stripAllList` {#var-stdenv-stripAllList}

List of directories to search for libraries and executables from which *all* symbols should be stripped. By default, it’s empty. Stripping all symbols is risky, since it may remove not just debug symbols but also ELF information necessary for normal execution.

##### `stripAllListTarget` {#var-stdenv-stripAllListTarget}

Like `stripAllList`, but only applies to packages’ target platform. By default, it’s empty. Useful when supporting cross compilation.

##### `stripAllFlags` {#var-stdenv-stripAllFlags}

Flags passed to the `strip` command applied to the files in the directories listed in `stripAllList`. Defaults to `-s -p` (i.e. `--strip-all --preserve-dates`).

##### `stripDebugList` {#var-stdenv-stripDebugList}

List of directories to search for libraries and executables from which only debugging-related symbols should be stripped. It defaults to `lib lib32 lib64 libexec bin sbin`.

##### `stripDebugListTarget` {#var-stdenv-stripDebugListTarget}

Like `stripDebugList`, but only applies to packages’ target platform. By default, it’s empty. Useful when supporting cross compilation.

##### `stripDebugFlags` {#var-stdenv-stripDebugFlags}

Title: Nix `stdenv` Install and Fixup Phases
Summary
This document outlines the `stdenv` install and fixup phases in Nix package building. The install phase places the package into the Nix store (`$out`) via `make install` by default. It's customizable with `dontInstall` (skip), `installTargets` (specify `make` targets), `installFlags`/`installFlagsArray` (additional `make` args), and `preInstall`/`postInstall` hooks. The subsequent fixup phase performs Nix-specific post-processing: moving documentation to `share/`, stripping debug info, applying `patchelf` on Linux to clean `RPATHs`, and rewriting interpreter paths in shell scripts. This phase is controlled by `dontFixup` (skip), `dontStrip` (prevent stripping), `dontMoveSbin` (keep files in `sbin`), `stripAllList`/`stripDebugList` (directories for symbol stripping, with `_Target` variants for cross-compilation), and `stripAllFlags`/`stripDebugFlags`.