rure: use the upstream Cargo.lock (#598183)

This commit is contained in:
Ross Smyth
2026-12-06 03:39:34 +00:00
committed by GitHub
4 changed files with 11 additions and 132 deletions

View File

@@ -1,61 +0,0 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 3
[[package]]
name = "aho-corasick"
version = "1.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ddd31a130427c27518df266943a5308ed92d4b226cc639f5a8f1002816174301"
dependencies = [
"memchr",
]
[[package]]
name = "libc"
version = "0.2.182"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6800badb6cb2082ffd7b6a67e6125bb39f18782f793520caee8cb8846be06112"
[[package]]
name = "memchr"
version = "2.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f8ca58f447f06ed17d5fc4043ce1b10dd205e060fb3ce5b979b8ed8e59ff3f79"
[[package]]
name = "regex"
version = "1.12.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e10754a14b9137dd7b1e3e5b0493cc9171fdd105e0ab477f51b72e7f3ac0e276"
dependencies = [
"aho-corasick",
"memchr",
"regex-automata",
"regex-syntax",
]
[[package]]
name = "regex-automata"
version = "0.4.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6e1dd4122fc1595e8162618945476892eefca7b88c52820e74af6262213cae8f"
dependencies = [
"aho-corasick",
"memchr",
"regex-syntax",
]
[[package]]
name = "regex-syntax"
version = "0.8.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dc897dd8d9e8bd1ed8cdad82b5966c3e0ecae09fb1907d58efaa013543185d0a"
[[package]]
name = "rure"
version = "0.2.5"
dependencies = [
"libc",
"regex",
]

View File

@@ -5,23 +5,19 @@
fetchCrate,
fixDarwinDylibNames,
haskellPackages,
nix-update-script,
}:
let
pin = lib.importJSON ./pin.json;
in
rustPlatform.buildRustPackage (finalAttrs: {
pname = "rure";
version = "0.2.5";
rustPlatform.buildRustPackage {
inherit (pin) pname version;
src = fetchCrate {
inherit (finalAttrs) pname version;
hash = "sha256-yff0u6kbLNgNLy0SFlvI6+q5J3N0NKjlYmIM2sus17o=";
};
src = fetchCrate pin;
# upstream doesn't ship a Cargo.lock, is generated by the update script
postPatch = ''
cp ${./Cargo.lock} Cargo.lock
'';
cargoLock.lockFile = ./Cargo.lock;
cargoHash = "sha256-EAy4ayXFfLruMihwb32tReHCVlEhz9eykVb3nbKhSAo=";
outputs = [
"out"
@@ -38,7 +34,7 @@ rustPlatform.buildRustPackage {
];
passthru = {
updateScript = ./update.sh;
updateScript = nix-update-script { };
tests.haskell-bindings = haskellPackages.regex-rure;
};
@@ -51,4 +47,4 @@ rustPlatform.buildRustPackage {
];
maintainers = [ lib.maintainers.sternenseemann ];
};
}
})

View File

@@ -1,5 +0,0 @@
{
"pname": "rure",
"version": "0.2.5",
"hash": "sha256:1fnpmk5xl332cbjshd3lfckvkspbr1dic4id5w6xhb0vm6xz9xy9"
}

View File

@@ -1,51 +0,0 @@
#!/usr/bin/env nix-shell
#! nix-shell -p nix jq curl cargo rsync
#! nix-shell -i bash
set -eu
cd "$(dirname "$0")"
crate=rure
echo "Getting latest version from crates.io API" >&2
curlOpts=(
-H "Accept: application/json"
-H "User-Agent: $crate update script (https://github.com/nixos/nixpkgs/)"
)
version="$(curl "${curlOpts[@]}" "https://crates.io/api/v1/crates/$crate" \
| jq -r .crate.max_stable_version)"
echo "Prefetching latest tarball from crates.io" >&2
url="https://crates.io/api/v1/crates/$crate/$version/download"
prefetch="$(nix-prefetch-url --print-path --type sha256 --unpack "$url")"
cat > pin.json <<EOF
{
"pname": "$crate",
"version": "$version",
"hash": "sha256:$(printf '%s' "$prefetch" | head -n1)"
}
EOF
echo "Generating updated Cargo.lock" >&2
tmp="$(mktemp -d)"
cleanup() {
echo "Removing $tmp" >&2
rm -rf "$tmp"
}
trap cleanup EXIT
rsync -a --chmod=ugo=rwX "$(printf '%s' "$prefetch" | tail -n1)/" "$tmp"
pushd "$tmp"
cargo update
popd
cp "$tmp/Cargo.lock" ./Cargo.lock