Home Explore Blog Models CI



nixpkgs

18th chunk of `doc/stdenv/stdenv.chapter.md`
8b3bf9f7ad76074b0bd537192159a5c55fbf873aea8e07d30000000100000fde
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.

:::{.example #ex-gdb-debug-symbols-socat}

# Enable debug symbols for use with GDB

To make GDB find debug information for the `socat` package and its dependencies, you can use the following `shell.nix`:

```nix
{
  pkgs ? import <nixpkgs> {
    config = { };
    overlays = [
      (final: prev: {
        ncurses = prev.ncurses.overrideAttrs { separateDebugInfo = true; };
        readline = prev.readline.overrideAttrs { separateDebugInfo = true; };

Title: Nix `stdenv` Fixup Phase Configuration and Debug Symbol Separation
Summary
This text details Nix `stdenv` fixup phase configuration, including `stripAllList` for risky complete symbol stripping and `stripDebugList` for stripping only debug symbols from specified directories, both with `_Target` variants for cross-compilation and `stripAllFlags`/`stripDebugFlags` for command options. `stripExclude` prevents stripping specific files/paths. Other variables manage `RPATH` pruning (`dontPatchELF`), interpreter path rewriting (`dontPatchShebangs`), libtool `.la` file dependencies (`dontPruneLibtoolFiles`), and forcing directory moves to `share` (`forceShare`). `setupHook` exports package hooks, while `preFixup` and `postFixup` allow custom fixup steps. Finally, `separateDebugInfo` enables C/++ debug info separation into a dedicated `debug` output, organized by build ID for debuggers like GDB, as exemplified by a `socat` case.