From 61d94d4f33db1f3c28938b30a6422b0a581e45d3 Mon Sep 17 00:00:00 2001 From: Peder Bergebakken Sundt Date: Thu, 12 Jun 2025 15:18:12 +0200 Subject: [PATCH] ldd --- overlays.nix | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/overlays.nix b/overlays.nix index 85e913c..edaeb67 100755 --- a/overlays.nix +++ b/overlays.nix @@ -259,6 +259,55 @@ let } ); + # usage: nix-build ./dev.nix -A .tests.checkLdd + overlays.withTestCheckLdd = mkDerivationOverlay ( + final: prev: prevStdenv: finalAttrs: prevAttrs: { + passthru = prevAttrs.passthru or { } // { + tests = prevAttrs.tests or { } // { + checkLdd = + prev.runCommandLocal "${finalAttrs.finalPackage.name}-ldd" + { + nativeBuildInputs = [ + prev.fd + ]; + } + '' + worker() ( + local output + set +e + output="$(ldd "$1")" + if [[ $? -ne 0 ]] || grep <<<"$output" -q " not found"; then + echo "$1" + # TODO: show executable permission errors too + grep <<<"$output" " not found" + touch any_error + fi + ) + fd_args=( + . + ${ + lib.pipe finalAttrs.finalPackage.outputs [ + (map (output: finalAttrs.finalPackage.${output})) + lib.escapeShellArgs + ] + } + --type f + --hidden + --no-ignore + --follow # symlinks + -x bash -c "$(declare -f worker); worker \"\$@\"" + ) + fd "''${fd_args[@]}" + + if [[ ! -e any_error ]]; then + touch $out + fi + ''; + }; + }; + } + ); + # TODO: this way of overriding does not work # Not a treewide enable, just for a single derivation # usage: nix-build . -A .withCuda @@ -566,6 +615,7 @@ in overlays.withUnpacked overlays.withTestMainProgram overlays.withShellCheck + overlays.withTestCheckLdd # overlays.withCudaOrRocm # WIP overlays.withCcache # WIP overlays.withTwostagePythonBuildPassthru