about summary refs log tree commit diff
diff options
context:
space:
mode:
authorsqualus <squalus@squalus.net>2024-08-10 08:33:15 -0700
committersqualus <squalus@squalus.net>2024-08-10 08:36:04 -0700
commit5793fb5b9e2e6031a090649911e540597cf194de (patch)
tree56911e7782ab18d0ce518a6262f6c06d15ce3e87
parent615639f3697052a377f22dfce04630464121998b (diff)
osquery: fix build
Patch toolchain rpath manually instead of using autoPatchelfHook

Workaround for #333710

Fixes #332533
-rw-r--r--pkgs/tools/system/osquery/default.nix4
-rw-r--r--pkgs/tools/system/osquery/toolchain-bin.nix19
2 files changed, 18 insertions, 5 deletions
diff --git a/pkgs/tools/system/osquery/default.nix b/pkgs/tools/system/osquery/default.nix
index 4c9d5b54cb0f4..8413c2e9f33ad 100644
--- a/pkgs/tools/system/osquery/default.nix
+++ b/pkgs/tools/system/osquery/default.nix
@@ -6,6 +6,7 @@
 , git
 , perl
 , python3
+, stdenv
 , stdenvNoCC
 , ninja
 , autoPatchelfHook
@@ -13,6 +14,7 @@
 , jq
 , removeReferencesTo
 , nixosTests
+, file
 }:
 
 let
@@ -50,7 +52,7 @@ let
     sha256 = opensslSha256;
   };
 
-  toolchain = import ./toolchain-bin.nix { inherit autoPatchelfHook stdenvNoCC lib fetchzip; };
+  toolchain = import ./toolchain-bin.nix { inherit stdenv lib fetchzip file; };
 
 in
 
diff --git a/pkgs/tools/system/osquery/toolchain-bin.nix b/pkgs/tools/system/osquery/toolchain-bin.nix
index d23b3ca1867c0..dd1ff9264d3c0 100644
--- a/pkgs/tools/system/osquery/toolchain-bin.nix
+++ b/pkgs/tools/system/osquery/toolchain-bin.nix
@@ -1,4 +1,4 @@
-{ stdenvNoCC, lib, autoPatchelfHook, fetchzip }:
+{ stdenv, lib, fetchzip, file }:
 let
 
   version = "1.1.0";
@@ -16,21 +16,32 @@ let
 
 in
 
-stdenvNoCC.mkDerivation {
+stdenv.mkDerivation {
 
   name = "osquery-toolchain-bin";
 
   inherit version;
 
-  src = fetchzip dist.${stdenvNoCC.hostPlatform.system};
+  src = fetchzip dist.${stdenv.hostPlatform.system};
 
-  nativeBuildInputs = [ autoPatchelfHook ];
+  nativeBuildInputs = [ file ];
 
   installPhase = ''
     mkdir $out
     cp -r * $out
   '';
 
+  # autoPatchelfHook cannot be used here because of https://github.com/NixOS/nixpkgs/issues/333710
+  postFixup = ''
+    read -r interpreter < "$NIX_BINTOOLS"/nix-support/dynamic-linker
+    for file in $(find "$out"/usr/bin -type f -executable); do
+      if [[ $(file "$file") == *ELF*dynamically* ]]; then
+        patchelf --interpreter "$interpreter" "$file"
+        patchelf --set-rpath "$out/usr/lib" "$file"
+      fi
+    done
+  '';
+
   meta = with lib; {
     description = "A LLVM-based toolchain for Linux designed to build a portable osquery";
     homepage = "https://github.com/osquery/osquery-toolchain";