This commit is contained in:
2025-06-12 15:18:12 +02:00
parent 34a65b5ca3
commit 61d94d4f33

View File

@@ -259,6 +259,55 @@ let
}
);
# usage: nix-build ./dev.nix -A <package>.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 <package>.withCuda
@@ -566,6 +615,7 @@ in
overlays.withUnpacked
overlays.withTestMainProgram
overlays.withShellCheck
overlays.withTestCheckLdd
# overlays.withCudaOrRocm # WIP
overlays.withCcache # WIP
overlays.withTwostagePythonBuildPassthru