Home Explore Blog Models CI



nixpkgs

doc/hooks/autopatchelf.section.md
1ed3e36e231696b5e1bd832f9acabfbfdb1f58a03016181e000000030000059c
# autoPatchelfHook {#setup-hook-autopatchelfhook}

This is a special setup hook which helps in packaging proprietary software in that it automatically tries to find missing shared library dependencies of ELF files based on the given `buildInputs` and `nativeBuildInputs`.

You can also specify a `runtimeDependencies` variable which lists dependencies to be unconditionally added to the rpath of all executables. This is useful for programs that use `dlopen` to load libraries at runtime.

In certain situations you may want to run the main command (`autoPatchelf`) of the setup hook on a file or a set of directories instead of unconditionally patching all outputs. This can be done by setting the `dontAutoPatchelf` environment variable to a non-empty value.

By default `autoPatchelf` will fail as soon as any ELF file requires a dependency which cannot be resolved via the given build inputs. In some situations you might prefer to just leave missing dependencies unpatched and continue to patch the rest. This can be achieved by setting the `autoPatchelfIgnoreMissingDeps` environment variable to a non-empty value. `autoPatchelfIgnoreMissingDeps` can be set to a list like `autoPatchelfIgnoreMissingDeps = [ "libcuda.so.1" "libcudart.so.1" ];` or to `[ "*" ]` to ignore all missing dependencies.

The `autoPatchelf` command also recognizes a `--no-recurse` command line flag, which prevents it from recursing into subdirectories.

Chunks
b77d52bc (1st chunk of `doc/hooks/autopatchelf.section.md`)
Title: autoPatchelfHook
Summary
The `autoPatchelfHook` is a setup hook designed to assist in packaging proprietary software by automatically identifying and patching missing shared library dependencies for ELF files, based on `buildInputs` and `nativeBuildInputs`. It allows for specifying `runtimeDependencies` for programs using `dlopen`, and provides control over its operation through variables like `dontAutoPatchelf` (to apply to specific files/directories) and `autoPatchelfIgnoreMissingDeps` (to prevent failures due to unresolved dependencies). Additionally, the `autoPatchelf` command supports a `--no-recurse` flag to limit its scope.