make cargo lock

This commit is contained in:
2025-09-03 12:22:15 +02:00
parent ccb80532a5
commit 08e6f0dbc6

View File

@@ -1198,6 +1198,38 @@ enqueue-nixpkgs-review *$prs:
done
# === patch helpers ===
[no-cd]
make-cargo-lock-patch $attrpath=`just _a_package`:
#!/usr/bin/env -S bash -euo pipefail
cargo_path=$( nix-build . -A cargo --no-out-link )
src_unpacked=$( NIX_PATH="nixpkgs-overlays=$(realpath "{{rootdir}}/overlays.nix")" nix-build . -A ${attrpath}.src.unpacked --no-out-link )
cargo_lock=$(fzf --walker=file,hidden --walker-root "$src_unpacked/" --query Cargo.lock)
[[ -s "$cargo_lock" ]]
cargo_toml=$(sed <<<"$cargo_lock" -e "s/\.lock$/.toml/")
[[ -s "$cargo_toml" ]]
TMP_DIR=$(mktemp -d)
$cargo_path/bin/cargo generate-lockfile --manifest-path "$cargo_toml" -Z unstable-options --lockfile-path "$TMP_DIR/Cargo.lock"
delta "$cargo_lock" "$TMP_DIR/Cargo.lock" --paging never ||:
attrdir=$(dirname "$(nix eval --log-format raw --file default.nix "$attrpath".meta.position --raw | cut -d: -f1 ||:)" ||:)
if [[ -n "${attrdir:-}" && -d "$attrdir" ]]; then
fd . "${attrdir}/" --type file --list-details
fi
echo "Where to put the patch?"
dest=$(gum input --value="$(realpath --canonicalize-missing "${attrdir:-.}/cargo-lock.patch")")
[[ -n "$dest" ]]
[[ ! -f "$dest" ]] || gum confirm "WARNING: '$dest' exists, overwrite?"
{
echo "--- $(realpath "$cargo_lock" | cut -d/ -f5-)"
echo "+++ $(realpath "$cargo_lock" | cut -d/ -f5-)"
diff --unified "$cargo_lock" "$TMP_DIR/Cargo.lock" | tail -n+3
} >"$dest" ||:
echo "$dest"
# === format helpers ===
[no-cd]