From fbdced9bb35a7a9619bfeab7a0244fd603fa6b03 Mon Sep 17 00:00:00 2001 From: Emily Date: Wed, 13 Nov 2024 12:23:30 +0000 Subject: [PATCH] folly: fix split outputs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Downstream derivations were picking up references to the `dev` output through indirect `__FILE__` usage in the headers. I borrowed and modified this trick from the Boost package, where I believe vcunat originated it. It’s not very pretty and it should be in a hook or something, but it works at a pinch. --- pkgs/by-name/fo/folly/package.nix | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/pkgs/by-name/fo/folly/package.nix b/pkgs/by-name/fo/folly/package.nix index b5999f17cbd0..050cbf86bcb3 100644 --- a/pkgs/by-name/fo/folly/package.nix +++ b/pkgs/by-name/fo/folly/package.nix @@ -7,6 +7,7 @@ cmake, ninja, pkg-config, + removeReferencesTo, boost, double-conversion, @@ -54,6 +55,7 @@ stdenv.mkDerivation (finalAttrs: { cmake ninja pkg-config + removeReferencesTo ]; # See CMake/folly-deps.cmake in the Folly source tree. @@ -113,6 +115,18 @@ stdenv.mkDerivation (finalAttrs: { '@CMAKE_INSTALL_FULL_INCLUDEDIR@' ''; + postFixup = '' + # Sanitize header paths to avoid runtime dependencies leaking in + # through `__FILE__`. + ( + shopt -s globstar + for header in "$dev/include"/**/*.h; do + sed -i "1i#line 1 \"$header\"" "$header" + remove-references-to -t "$dev" "$header" + done + ) + ''; + passthru = { # folly-config.cmake, will `find_package` these, thus there should be # a way to ensure abi compatibility.