nixpkgs/pkgs/build-support
aszlig 1cba74dfc1
setup-hooks: Add autoPatchelfHook
I originally wrote this for packaging proprietary games in Vuizvui[1]
but I thought it would be generally useful as we have a fair amount of
proprietary software lurking around in nixpkgs, which are a bit tedious
to maintain, especially when the library dependencies change after an
update.

So this setup hook searches for all ELF executables and libraries in the
resulting output paths after install phase and uses patchelf to set the
RPATH and interpreter according to what dependencies are available
inside the builder.

For example consider something like this:

stdenv.mkDerivation {
  ...
  nativeBuildInputs = [ autoPatchelfHook ];
  buildInputs = [ mesa zlib ];
  ...
}

Whenever for example an executable requires mesa or zlib, the RPATH will
automatically be set to the lib dir of the corresponding dependency.

If the library dependency is required at runtime, an attribute called
runtimeDependencies can be used to list dependencies that are added to
all executables that are discovered unconditionally.

Beside this, it also makes initial packaging of proprietary software
easier, because one no longer has to manually figure out the
dependencies in the first place.

[1]: https://github.com/openlab-aux/vuizvui

Signed-off-by: aszlig <aszlig@nix.build>
Closes: #34506
2018-02-10 00:27:24 +05:30
..
agda
bintools-wrapper stdenv-setup: Ease the transition with native builds 2017-12-30 22:04:23 -05:00
build-dotnet-package treewide: Manual fix more pkg-config build-inputs 2017-09-21 15:49:54 -04:00
build-fhs-userenv chrootenv: rewrite on top of GLib 2017-12-30 22:28:38 +00:00
buildenv Merge pull request #27780 from tilpner/overridable-buildenv 2017-09-14 17:26:33 +02:00
cc-wrapper Merge branch 'master' into staging 2017-12-31 09:53:49 +01:00
docker treewide: Fix deps in a few other fixed output derivations 2018-01-10 11:18:44 -05:00
dotnetbuildhelpers
dotnetenv
emacs Add setFunctionArgs lib function. 2018-01-31 14:02:19 -05:00
expand-response-params expand-response-params: Build more normally 2017-08-25 15:10:02 -04:00
fetchbower Merge remote-tracking branch 'upstream/master' into staging 2018-01-14 21:18:27 +02:00
fetchbzr treewide: Fetchers should use stdenvNoCC. 2018-01-10 11:18:44 -05:00
fetchcvs treewide: Fetchers should use stdenvNoCC. 2018-01-10 11:18:44 -05:00
fetchdarcs Merge remote-tracking branch 'upstream/master' into staging 2018-01-14 21:18:27 +02:00
fetchegg treewide: Fetchers should use stdenvNoCC. 2018-01-10 11:18:44 -05:00
fetchfossil treewide: Fixed output fetch* derivations should use nativeBuildInputs 2018-01-09 20:14:46 -05:00
fetchgit nix-prefetch-git: fix extraction of submodule hashes on latest git 2018-01-24 20:18:59 +02:00
fetchgitlocal
fetchgx Merge remote-tracking branch 'upstream/master' into staging 2018-01-14 21:18:27 +02:00
fetchhg treewide: Fetchers should use stdenvNoCC. 2018-01-10 11:18:44 -05:00
fetchipfs treewide: Fixed output fetch* derivations should use nativeBuildInputs 2018-01-09 20:14:46 -05:00
fetchmavenartifact
fetchmtn treewide: Fetchers should use stdenvNoCC. 2018-01-10 11:18:44 -05:00
fetchnuget treewide: Fetchers should use stdenvNoCC. 2018-01-10 11:18:44 -05:00
fetchpatch fetchpatch: Add support for an arbitrary extra prefix 2018-01-18 12:19:49 -05:00
fetchrepoproject treewide: Fetchers should use stdenvNoCC. 2018-01-10 11:18:44 -05:00
fetchs3 treewide: Fetchers should use stdenvNoCC. 2018-01-10 11:18:44 -05:00
fetchsvn treewide: Fetchers should use stdenvNoCC. 2018-01-10 11:18:44 -05:00
fetchsvnrevision
fetchsvnssh treewide: Fetchers should use stdenvNoCC. 2018-01-10 11:18:44 -05:00
fetchurl treewide: Fetchers should use stdenvNoCC. 2018-01-10 11:18:44 -05:00
fetchzip fetchzip and friends: Set "name" to "source" by default 2017-10-30 17:17:07 +01:00
gcc-wrapper-old gcc-wrapper-old: grab name of dynamicLinker for bintools 2018-01-05 18:55:13 -06:00
icon-conv-tools
kernel platforms.nix: Clean up more 'uboot' legacy 2017-11-05 17:06:59 +02:00
libredirect libredirect: add description 2017-12-14 19:03:35 +00:00
make-desktopitem
make-startupitem make-autostartitem: Use the right path for storing the desktop files 2017-07-06 00:44:41 +02:00
make-symlinks
mkshell mkShell: add builder (#30975) 2017-12-20 23:42:07 +00:00
mono-dll-fixer
nuke-references
ocaml
release schedulingPriority should be an int, fix check-meta type and in-tree use 2018-01-09 07:25:24 -06:00
remove-references-to Add removeReferencesTo for removing specific refs 2017-03-09 12:01:55 +00:00
rust way-cooler: 0.6.2 -> 0.8.0 2018-02-04 05:17:53 +03:00
setup-hooks setup-hooks: Add autoPatchelfHook 2018-02-10 00:27:24 +05:30
singularity-tools singularity: 2.2 -> 2.4 2017-12-21 10:50:06 +11:00
src-only
substitute
substitute-files
templaterpm
upstream-updater
vm runInLinuxVM: Use QEMU command line that works on other architectures 2018-01-30 16:57:27 +02:00
vsenv
build-maven.nix
build-pecl.nix Revert "fix phpPackages memcache,memcached,xdebug" 2017-12-10 12:12:43 +01:00
closure-info.nix closure-info: another half-blind attempt to fix on Hydra 2017-11-01 08:07:15 +01:00
dhall-to-nix.nix Add a pkgs.dhallToNix utility 2017-01-26 20:11:49 -08:00
plugins.nix Ultrastar (#26524) 2017-06-14 11:29:31 +02:00
replace-dependency.nix
safe-discard-string-context.nix callCabal2nix: Fix calling with a path in the store. 2018-01-11 10:17:56 -05:00
setup-systemd-units.nix Add setupSystemdUnits function. 2017-03-24 15:47:51 -04:00
source-from-head-fun.nix
trivial-builders.nix makeSetupHook: make the default name "hook" overridable 2017-12-19 01:41:31 +00:00