Skip to content

Commit fab55ca

Browse files
authored
Update cargo-hyperlight version to 0.1.14 (#1754)
* Update cargo-hyperlight version to 0.1.14 Signed-off-by: Yosh <github@yosh.is> * Add script to update `Flake.nix` cargo hl dep Signed-off-by: Yosh <github@yosh.is> --------- Signed-off-by: Yosh <github@yosh.is>
1 parent d604978 commit fab55ca

3 files changed

Lines changed: 81 additions & 9 deletions

File tree

‎Justfile‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ bin-suffix := if os() == "windows" { ".bat" } else { ".sh" }
88
nightly-toolchain := "nightly-2026-02-27"
99
# Pinned cargo-hyperlight version used to build the guest sysroot. Keep this in
1010
# lockstep with the version pinned in flake.nix.
11-
cargo-hyperlight-version := "0.1.12"
11+
cargo-hyperlight-version := "0.1.14"
1212

1313
################
1414
### cross-rs ###
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
#!/usr/bin/env bash
2+
set -Eeuo pipefail
3+
4+
## DESCRIPTION:
5+
##
6+
## Pins the latest published cargo-hyperlight in the Justfile and in
7+
## flake.nix. The Justfile only needs the version, flake.nix also needs
8+
## the SRI hash of the .crate tarball. Both come from the crates.io
9+
## sparse index, so no download and no Nix are needed.
10+
##
11+
## PRE-REQS:
12+
##
13+
## curl, jq, and sed.
14+
15+
CRATE=cargo-hyperlight
16+
ROOT="$(git rev-parse --show-toplevel)"
17+
cd "$ROOT"
18+
19+
for tool in curl jq sed; do
20+
command -v "$tool" >/dev/null || { echo "error: $tool is required" >&2; exit 1; }
21+
done
22+
23+
# `sed -i` takes different arguments on GNU and BSD, so edit via a temp file.
24+
sedi() {
25+
local file=$1
26+
shift
27+
if ! sed "$@" "$file" > "$file.tmp"; then
28+
rm -f "$file.tmp"
29+
exit 1
30+
fi
31+
mv "$file.tmp" "$file"
32+
}
33+
34+
check() {
35+
grep -qF "$2" "$1" || { echo "error: failed to update $1 with: $2" >&2; exit 1; }
36+
}
37+
38+
# Index paths are bucketed by the first four characters of the crate name.
39+
INDEX="https://index.crates.io/${CRATE:0:2}/${CRATE:2:2}/$CRATE"
40+
41+
# Entries are in publication order, so the last released one is the latest.
42+
read -r VERSION CKSUM < <(curl -fsSL "$INDEX" |
43+
jq -rs 'map(select((.yanked | not) and (.vers | contains("-") | not))) | last | "\(.vers) \(.cksum)"')
44+
45+
# The index gives the checksum in hex, Nix wants it base64 encoded.
46+
# shellcheck disable=SC2001 # no parameter expansion pairs up hex digits
47+
HASH="sha256-$(printf %b "$(sed 's/../\\x&/g' <<< "$CKSUM")" | base64 | tr -d '\n')"
48+
echo "latest release: $VERSION ($HASH)"
49+
50+
sedi Justfile "s|^cargo-hyperlight-version := \".*\"|cargo-hyperlight-version := \"$VERSION\"|"
51+
52+
# Both fields are matched inside the fetchurl block, where they are unique.
53+
BLOCK='/cargo-hyperlight = let/,/^ *};$/'
54+
sedi flake.nix \
55+
-e "$BLOCK s|version = \"[^\"]*\"|version = \"$VERSION\"|" \
56+
-e "$BLOCK s|hash = \"[^\"]*\"|hash = \"$HASH\"|"
57+
58+
check Justfile "cargo-hyperlight-version := \"$VERSION\""
59+
check flake.nix "version = \"$VERSION\""
60+
check flake.nix "hash = \"$HASH\""
61+
62+
echo "pinned cargo-hyperlight $VERSION in Justfile and flake.nix"

‎flake.nix‎

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -227,16 +227,26 @@
227227

228228
buildRustPackageClang = rust-platform.buildRustPackage.override { stdenv = clangStdenv; };
229229

230-
cargo-hyperlight = buildRustPackageClang rec {
230+
# Keep the version in lockstep with the one pinned in the Justfile.
231+
# `dev/update-cargo-hyperlight-version.sh` updates both.
232+
cargo-hyperlight = let
233+
version = "0.1.14";
234+
# The .crate tarball is hashed flat, so the pin can be refreshed
235+
# from the checksum crates.io publishes, without running Nix.
236+
src = fetchurl {
237+
url = "https://static.crates.io/crates/cargo-hyperlight/cargo-hyperlight-${version}.crate";
238+
name = "cargo-hyperlight-${version}.tar.gz";
239+
hash = "sha256-xS8cnUthc677Zv3C4+ES3bNZ/i+9uq/hubol96xXizk=";
240+
};
241+
in buildRustPackageClang {
231242
pname = "cargo-hyperlight";
232-
version = "0.1.14-pre";
233-
src = fetchFromGitHub {
234-
owner = "hyperlight-dev";
235-
repo = "cargo-hyperlight";
236-
rev = "33384c0c4ed9dea4f0525943809fc444c41a27df";
237-
hash = "sha256-A2/SNHCdPPzW86bd00IucZEyZHZWDqXVKPccZULcEu0=";
243+
inherit version src;
244+
# The tarball ships a Cargo.lock, so the dependencies need no
245+
# vendor hash of their own.
246+
cargoDeps = rust-platform.importCargoLock {
247+
lockFile = runCommand "cargo-hyperlight-${version}-Cargo.lock" {}
248+
"tar -xzOf ${src} cargo-hyperlight-${version}/Cargo.lock > $out";
238249
};
239-
cargoHash = "sha256-ImWnNzXvDKokML0BDyyjifrZ1bnG6ymXt5vAMRIpwUY==";
240250
doCheck = false;
241251
};
242252
in (buildRustPackageClang (mkDerivationAttrs: {

0 commit comments

Comments
 (0)