Home Explore Blog CI



nixpkgs

17th chunk of `doc/stdenv/stdenv.chapter.md`
3819582d28f4217ff5a4f54f6ca87694285233aca30bb4900000000100001109
##### `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}

Flags passed to the `strip` command applied to the files in the directories listed in `stripDebugList`. Defaults to `-S -p` (i.e. `--strip-debug --preserve-dates`).

##### `stripExclude` {#var-stdenv-stripExclude}

A list of filenames or path patterns to avoid stripping. A file is excluded if its name _or_ path (from the derivation root) matches.

This example prevents all `*.rlib` files from being stripped:

```nix
stdenv.mkDerivation {
  # ...
  stripExclude = [ "*.rlib" ];
}
```

This example prevents files within certain paths from being stripped:

```nix
stdenv.mkDerivation {
  # ...
  stripExclude = [ "lib/modules/*/build/*" ];
}
```

##### `dontPatchELF` {#var-stdenv-dontPatchELF}

If set, the `patchelf` command is not used to remove unnecessary `RPATH` entries. Only applies to Linux.

##### `dontPatchShebangs` {#var-stdenv-dontPatchShebangs}

If set, scripts starting with `#!` do not have their interpreter paths rewritten to paths in the Nix store. See [](#patch-shebangs.sh) on how patching shebangs works.

##### `dontPruneLibtoolFiles` {#var-stdenv-dontPruneLibtoolFiles}

If set, libtool `.la` files associated with shared libraries won’t have their `dependency_libs` field cleared.

##### `forceShare` {#var-stdenv-forceShare}

The list of directories that must be moved from `$out` to `$out/share`. Defaults to `man doc info`.

##### `setupHook` {#var-stdenv-setupHook}

A package can export a [setup hook](#ssec-setup-hooks) by setting this variable. The setup hook, if defined, is copied to `$out/nix-support/setup-hook`. Environment variables are then substituted in it using `substituteAll`.

##### `preFixup` {#var-stdenv-preFixup}

Hook executed at the start of the fixup phase.

##### `postFixup` {#var-stdenv-postFixup}

Hook executed at the end of the fixup phase.

##### `separateDebugInfo` {#stdenv-separateDebugInfo}

If set to `true`, the standard environment will enable debug information in C/C++ builds. After installation, the debug information will be separated from the executables and stored in the output named `debug`. (This output is enabled automatically; you don’t need to set the `outputs` attribute explicitly.) To be precise, the debug information is stored in `debug/lib/debug/.build-id/XX/YYYY…`, where \<XXYYYY…\> is the \<build ID\> of the binary — a SHA-1 hash of the contents of the binary. Debuggers like GDB use the build ID to look up the separated debug information.

Title: Detailed Control Over Nix Fixup Phase: Stripping, Patching, and Debug Information
Summary
This section provides an in-depth look at variables controlling the Nix fixup phase. It covers fine-grained control over stripping symbols from binaries (`dontStrip`, `stripAllList`, `stripDebugList`, `stripExclude`), patching ELF files (`dontPatchELF`), and rewriting shebangs (`dontPatchShebangs`). Additionally, it explains options for moving directories to `$out/share` (`forceShare`), setting up hooks (`setupHook`), and separating debug information into a dedicated `debug` output (`separateDebugInfo`).