From 19e73e9aab069df55f9ea0a87f5cadae3bd59ad4 Mon Sep 17 00:00:00 2001 From: Audrey Dutcher Date: Mon, 14 Jul 2025 15:44:55 -0700 Subject: [PATCH] jeez. it works --- package.nix | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/package.nix b/package.nix index 5fb48a1..63d0737 100644 --- a/package.nix +++ b/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