34 lines
937 B
Nix
34 lines
937 B
Nix
{
|
|
lib,
|
|
runCommand,
|
|
}:
|
|
{
|
|
name,
|
|
pkgList,
|
|
fileGlobs ? [ "bin/*" "lib/*.so.*"],
|
|
fileFindPredicates ? "-type f",
|
|
pkgProcessor ? pkg: pkg,
|
|
}:
|
|
let
|
|
processedList = map pkgProcessor pkgList;
|
|
globPredicates = lib.concatMapStringsSep " -or " (g: "-path \"./${lib.strings.removePrefix "/" g}\"") fileGlobs;
|
|
copiedBins = runCommand name {} ''
|
|
mkdir -p $out/bins
|
|
for pkgPath in ${lib.concatStringsSep " " processedList}; do
|
|
cd $pkgPath
|
|
find . \( ${globPredicates} \) ${fileFindPredicates} | while read -r filename; do
|
|
fullPath="$pkgPath/$filename"
|
|
destPath="$out/bins/$(basename $filename)"
|
|
if [[ $(head -c 4 "$fullPath") != $'\x7fELF' ]]; then
|
|
continue
|
|
fi
|
|
if [[ -e "$destPath" ]]; then
|
|
echo "Uh oh: conflict for populating $destPath from $fullPath"
|
|
exit 1
|
|
fi
|
|
cp $fullPath $out/bins
|
|
done
|
|
done
|
|
'';
|
|
in copiedBins
|