diff --git a/nix/mkAtmApp.nix b/nix/mkAtmApp.nix index 68a4c37..272bd33 100644 --- a/nix/mkAtmApp.nix +++ b/nix/mkAtmApp.nix @@ -172,6 +172,27 @@ pkgs.stdenv.mkDerivation (finalAttrs: { cp -rL "$bcpp_store/node_modules/@serialport/bindings-cpp/prebuilds" $out/node_modules/@serialport/bindings-cpp/prebuilds cp "$bcpp_store/node_modules/@serialport/bindings-cpp/package.json" $out/node_modules/@serialport/bindings-cpp/package.json + # bindings-cpp ships prebuilds for every platform it supports: android, + # win32, darwin, and linux for several arches in both glibc and musl. Keep + # only the one this system can actually load. + # + # This is load-bearing on aarch64, not just tidiness. On x86_64 autoPatchelf + # skipped the foreign prebuilds because their ELF architecture did not match + # the host. On aarch64 the android-arm64 prebuild IS the host architecture, + # so autoPatchelf tries to patch it and fails hunting for Android's + # liblog.so and libc++_shared.so, which do not exist on NixOS. First Pi + # build died exactly there. + # + # Pruning rather than extending autoPatchelfIgnoreMissingDeps: teaching + # autoPatchelf to tolerate a binary we never load, for a platform we do not + # target, is the wrong shape of fix. The musl entry in that list below is + # the same problem solved the other way, and is now redundant. + keep_prebuild=${if pkgs.stdenv.hostPlatform.isAarch64 then "linux-arm64" else "linux-x64"} + find $out/node_modules/@serialport/bindings-cpp/prebuilds -mindepth 1 -maxdepth 1 \ + ! -name "$keep_prebuild" -exec rm -rf {} + + rm -f $out/node_modules/@serialport/bindings-cpp/prebuilds/*/*.musl.node + echo "serialport prebuilds kept: $(ls $out/node_modules/@serialport/bindings-cpp/prebuilds)/$(ls $out/node_modules/@serialport/bindings-cpp/prebuilds/"$keep_prebuild")" + copy_pnpm_pkg @serialport/bindings-interface $out/node_modules/@serialport/bindings-interface copy_pnpm_pkg @serialport/binding-mock $out/node_modules/@serialport/binding-mock