diff --git a/pkgs/development/tools/uniffi-bindgen/default.nix b/pkgs/development/tools/uniffi-bindgen/default.nix index 1073152732e0..d30e09b8e94b 100644 --- a/pkgs/development/tools/uniffi-bindgen/default.nix +++ b/pkgs/development/tools/uniffi-bindgen/default.nix @@ -35,6 +35,8 @@ rustPlatform.buildRustPackage rec { --suffix PATH : ${lib.strings.makeBinPath [ rustfmt ktlint yapf rubocop ] } ''; + passthru.updateScript = ./update.sh; + meta = with lib; { description = "Toolkit for building cross-platform software components in Rust"; homepage = "https://mozilla.github.io/uniffi-rs/"; diff --git a/pkgs/development/tools/uniffi-bindgen/update.sh b/pkgs/development/tools/uniffi-bindgen/update.sh new file mode 100755 index 000000000000..4815f6eedd6d --- /dev/null +++ b/pkgs/development/tools/uniffi-bindgen/update.sh @@ -0,0 +1,35 @@ +#!/usr/bin/env nix-shell +#! nix-shell -p nix cargo rsync nix-update +#! nix-shell -i bash + +set -euo pipefail + +if [[ -z "${UPDATE_NIX_ATTR_PATH+x}" ]]; then + echo "Error: run the following command from nixpkgs root:" >&2 + echo " nix-shell maintainers/scripts/update.nix --argstr package uniffi-bindgen" >&2 + exit 1 +fi + +targetLockfile="$(dirname "$0")/Cargo.lock" + +# Update version and hash +nix-update "$UPDATE_NIX_ATTR_PATH" + +# Update lockfile through `cargo update` +src=$(nix-build -A "${UPDATE_NIX_ATTR_PATH}.src" --no-out-link) + +tmp=$(mktemp -d) + +cleanup() { + echo "Removing $tmp" >&2 + rm -rf "$tmp" +} + +trap cleanup EXIT + +rsync -a --chmod=ugo=rwX "$src/" "$tmp" + +pushd "$tmp" +cargo update +cp "Cargo.lock" "$targetLockfile" +popd