From 08e6f0dbc60480178db41d44ad0099f5cb0d9ced Mon Sep 17 00:00:00 2001 From: Peder Bergebakken Sundt Date: Wed, 3 Sep 2025 12:22:15 +0200 Subject: [PATCH] make cargo lock --- justfile | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/justfile b/justfile index 371d650..3aa7466 100644 --- a/justfile +++ b/justfile @@ -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]