22 lines
1.0 KiB
Nix
22 lines
1.0 KiB
Nix
{ trunk, jq }:
|
|
trunk.overrideAttrs (old: {
|
|
nativeBuildInputs = (old.nativeBuildInputs or [ ]) ++ [ jq ];
|
|
|
|
# Patch the bundled libdeflate before Cargo validates its vendor checksums.
|
|
postPatch = (old.postPatch or "") + ''
|
|
libdeflateVendors=( "$cargoDepsCopy"/source-*/libdeflate-sys-1.23.1 )
|
|
if [ "''${#libdeflateVendors[@]}" -ne 1 ] || [ ! -d "''${libdeflateVendors[0]}" ]; then
|
|
echo "Expected exactly one vendored libdeflate-sys 1.23.1" >&2
|
|
exit 1
|
|
fi
|
|
libdeflateVendor="''${libdeflateVendors[0]}"
|
|
patch -d "$libdeflateVendor/libdeflate" -p1 < ${./libdeflate-gcc16.patch}
|
|
libdeflateHeader=libdeflate/lib/x86/cpu_features.h
|
|
libdeflateChecksum=$(sha256sum "$libdeflateVendor/$libdeflateHeader" | cut -d ' ' -f 1)
|
|
jq --arg path "$libdeflateHeader" --arg hash "$libdeflateChecksum" \
|
|
'.files[$path] = $hash' "$libdeflateVendor/.cargo-checksum.json" \
|
|
> "$libdeflateVendor/.cargo-checksum.json.new"
|
|
mv "$libdeflateVendor/.cargo-checksum.json.new" "$libdeflateVendor/.cargo-checksum.json"
|
|
'';
|
|
})
|