jeez. it works

This commit is contained in:
Audrey 2025-07-14 15:44:55 -07:00
parent 6a07d90f6f
commit 19e73e9aab
1 changed files with 16 additions and 4 deletions

View File

@ -5,17 +5,29 @@
{
name,
pkgList,
fileGlobs ? [ "bin/*" "lib/*"],
fileGlobs ? [ "bin/*" "lib/*.so.*"],
fileFindPredicates ? "-type f",
pkgProcessor ? pkg: pkg,
}:
let
processedList = map pkgProcessor pkgList;
globPredicates = lib.concatMapStringsSep " " (g: "-find ${g}") fileGlobs;
globPredicates = lib.concatMapStringsSep " -or " (g: "-path \"./${lib.strings.removePrefix "/" g}\"") fileGlobs;
copiedBins = runCommand name {} ''
mkdir -p $out/bins
find ${lib.concatStringsSep " " processedList} ${globPredicates} ${fileFindPredicates}| while read -r filepath; do
cp "$filepath" $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