kanata: download crate via CDN instead of API in updateScript

API has rate limit and requires user-agent while CDN does not.

https://crates.io/data-access#crate-content
This commit is contained in:
Lin Jian
2026-07-11 08:31:05 +08:00
parent 20b6c326e5
commit bf0349bdf8
+1 -1
View File
@@ -3,7 +3,7 @@ nix-update
importTree="(let tree = import ./.; in if builtins.isFunction tree then tree {} else tree)"
NEW_VERSION=$(nix-instantiate --eval -E "with $importTree; kanata.version" | tr -d '"')
karabinerDriverCrateVersion="$(curl -L "https://raw.githubusercontent.com/jtroo/kanata/refs/tags/v$NEW_VERSION/Cargo.lock" | tomlq | jq --raw-output '.package[] | select(.name | test("karabiner-driverkit")) |.version')"
newKarabinerDkVersion="$(curl -L "https://crates.io/api/v1/crates/karabiner-driverkit/$karabinerDriverCrateVersion/download" | tar xzvf - --strip-components=1 -O "karabiner-driverkit-$karabinerDriverCrateVersion/c_src/Karabiner-DriverKit-VirtualHIDDevice/version.json" | jq --raw-output0 .package_version)"
newKarabinerDkVersion="$(curl -L "https://static.crates.io/crates/karabiner-driverkit/karabiner-driverkit-$karabinerDriverCrateVersion.crate" | tar xzvf - --strip-components=1 -O "karabiner-driverkit-$karabinerDriverCrateVersion/c_src/Karabiner-DriverKit-VirtualHIDDevice/version.json" | jq --raw-output0 .package_version)"
oldDarwinVersion=$(nix-instantiate --eval -E "with $importTree; kanata.passthru.darwinDriverVersion" | tr -d '"')
nixFile=$(nix-instantiate --eval --strict -A "kanata.meta.position" | sed -re 's/^"(.*):[0-9]+"$/\1/')
sed -i "$nixFile" -re "s|\"$oldDarwinVersion\"|\"$newKarabinerDkVersion\"|"