jeez. it works
This commit is contained in:
parent
6a07d90f6f
commit
19e73e9aab
20
package.nix
20
package.nix
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue