From a4ee94b741d865afb6f6280d4eb8786f66ed602e Mon Sep 17 00:00:00 2001
From: John Wiegley <johnw@newartisans.com>
Date: Tue, 4 Nov 2014 02:28:03 -0600
Subject: [PATCH] boost: correct the install names for darwin

This also makes the recent change for ledger unnecessary.
---
 pkgs/applications/office/ledger/3.0.nix      | 5 -----
 pkgs/development/libraries/boost/generic.nix | 5 +++++
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/pkgs/applications/office/ledger/3.0.nix b/pkgs/applications/office/ledger/3.0.nix
index 64fbf991713b..6118d377a79f 100644
--- a/pkgs/applications/office/ledger/3.0.nix
+++ b/pkgs/applications/office/ledger/3.0.nix
@@ -23,11 +23,6 @@ stdenv.mkDerivation {
   postInstall = ''
     mkdir -p $out/share/emacs/site-lisp/
     cp -v "$src/lisp/"*.el $out/share/emacs/site-lisp/
-  '' + stdenv.lib.optionalString stdenv.isDarwin ''
-    for i in date_time filesystem system iostreams regex unit_test_framework; do
-      boostlib=libboost_''$i.dylib
-      install_name_tool -change ''$boostlib ${boost}/lib/''$boostlib $out/bin/ledger
-    done
   '';
 
   meta = {
diff --git a/pkgs/development/libraries/boost/generic.nix b/pkgs/development/libraries/boost/generic.nix
index f4a78f201c9d..274b2486febe 100644
--- a/pkgs/development/libraries/boost/generic.nix
+++ b/pkgs/development/libraries/boost/generic.nix
@@ -118,8 +118,13 @@ stdenv.mkDerivation {
 
   preConfigure = ''
     NIX_LDFLAGS="$(echo $NIX_LDFLAGS | sed "s,$out,$lib,g")"
+    substituteInPlace tools/build/src/tools/clang-darwin.jam \
+      --replace '$(<[1]:D=)' "$lib/lib/\$(<[1]:D=)"
   '';
 
+  NIX_CFLAGS_LINK = stdenv.lib.optionalString stdenv.isDarwin
+                      "-headerpad_max_install_names";
+
   enableParallelBuilding = true;
 
   buildInputs = [ icu expat zlib bzip2 python ]